1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*******************************************************************************
3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
4103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius*   Copyright (C) 2004-2012, International Business Machines
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*******************************************************************************
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   file name:  utext.h
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   encoding:   US-ASCII
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   tab size:   8 (not used)
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   indentation:4
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   created on: 2004oct06
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   created by: Markus W. Scherer
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef __UTEXT_H__
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define __UTEXT_H__
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \file
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \brief C API: Abstract Unicode Text API
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The Text Access API provides a means to allow text that is stored in alternative
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * formats to work with ICU services.  ICU normally operates on text that is
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * stored in UTF-16 format, in (UChar *) arrays for the C APIs or as type
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UnicodeString for C++ APIs.
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ICU Text Access allows other formats, such as UTF-8 or non-contiguous
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UTF-16 strings, to be placed in a UText wrapper and then passed to ICU services.
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * There are three general classes of usage for UText:
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     Application Level Use.  This is the simplest usage - applications would
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     use one of the utext_open() functions on their input text, and pass
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     the resulting UText to the desired ICU service.
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     Second is usage in ICU Services, such as break iteration, that will need to
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     operate on input presented to them as a UText.  These implementations
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     will need to use the iteration and related UText functions to gain
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     access to the actual text.
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     The third class of UText users are "text providers."  These are the
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     UText implementations for the various text storage formats.  An application
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     or system with a unique text storage format can implement a set of
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     UText provider functions for that format, which will then allow
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *     ICU services to operate on that format.
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <em>Iterating over text</em>
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Here is sample code for a forward iteration over the contents of a UText
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code
55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    UChar32  c;
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    UText    *ut = whatever();
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    for (c=utext_next32From(ut, 0); c>=0; c=utext_next32(ut)) {
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *       // do whatever with the codepoint c here.
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    }
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * And here is similar code to iterate in the reverse direction, from the end
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of the text towards the beginning.
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    UChar32  c;
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    UText    *ut = whatever();
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    int      textLength = utext_nativeLength(ut);
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    for (c=utext_previous32From(ut, textLength); c>=0; c=utext_previous32(ut)) {
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *       // do whatever with the codepoint c here.
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    }
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <em>Characters and Indexing</em>
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Indexing into text by UText functions is nearly always in terms of the native
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * indexing of the underlying text storage.  The storage format could be UTF-8
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or UTF-32, for example.  When coding to the UText access API, no assumptions
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * can be made regarding the size of characters, or how far an index
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * may move when iterating between characters.
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * All indices supplied to UText functions are pinned to the length of the
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text.  An out-of-bounds index is not considered to be an error, but is
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * adjusted to be in the range  0 <= index <= length of input text.
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When an index position is returned from a UText function, it will be
89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a native index to the underlying text.  In the case of multi-unit characters,
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it will  always refer to the first position of the character,
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * never to the interior.  This is essentially the same thing as saying that
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a returned index will always point to a boundary between characters.
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When a native index is supplied to a UText function, all indices that
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * refer to any part of a multi-unit character representation are considered
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to be equivalent.  In the case of multi-unit characters, an incoming index
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be logically normalized to refer to the start of the character.
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It is possible to test whether a native index is on a code point boundary
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by doing a utext_setNativeIndex() followed by a utext_getNativeIndex().
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the index is returned unchanged, it was on a code point boundary.  If
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * an adjusted index is returned, the original index referred to the
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * interior of a character.
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <em>Conventions for calling UText functions</em>
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Most UText access functions have as their first parameter a (UText *) pointer,
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which specifies the UText to be used.  Unless otherwise noted, the
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * pointer must refer to a valid, open UText.  Attempting to
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * use a closed UText or passing a NULL pointer is a programming error and
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will produce undefined results or NULL pointer exceptions.
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The UText_Open family of functions can either open an existing (closed)
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UText, or heap allocate a new UText.  Here is sample code for creating
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a stack-allocated UText.
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    char     *s = whatever();  // A utf-8 string
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    U_ErrorCode status = U_ZERO_ERROR;
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    UText    ut = UTEXT_INITIALIZER;
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    utext_openUTF8(ut, s, -1, &status);
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    if (U_FAILURE(status)) {
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *        // error handling
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    } else {
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *        // work with the UText
126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    }
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Any existing UText passed to an open function _must_ have been initialized,
130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * either by the UTEXT_INITIALIZER, or by having been originally heap-allocated
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by an open function.  Passing NULL will cause the open function to
132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * heap-allocate and fully initialize a new UText.
133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
13950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/uchar.h"
14050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if U_SHOW_CPLUSPLUS_API
14150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/localpointer.h"
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/rep.h"
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/unistr.h"
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/chariter.h"
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_BEGIN
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UText;
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UText UText; /**< C typedef for struct UText. @stable ICU 3.6 */
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/***************************************************************************************
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   C Functions for creating UText wrappers around various kinds of text strings.
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ****************************************************************************************/
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Close function for UText instances.
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Cleans up, releases any resources being held by an open UText.
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * <p>
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   If the UText was originally allocated by one of the utext_open functions,
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   the storage associated with the utext will also be freed.
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   If the UText storage originated with the application, as it would with
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   a local or static instance, the storage will not be deleted.
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   An open UText can be reset to refer to new string by using one of the utext_open()
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   functions without first closing the UText.
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @param ut  The UText to be closed.
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @return    NULL if the UText struct was deleted by the close.  If the UText struct
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *            was originally provided by the caller to the open function, it is
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *            returned by this function, and may be safely used again in
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *            a subsequent utext_open.
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_close(UText *ut);
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
18450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if U_SHOW_CPLUSPLUS_API
18550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
18650294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_NAMESPACE_BEGIN
18750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
18850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/**
18950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * \class LocalUTextPointer
19050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * "Smart pointer" class, closes a UText via utext_close().
19150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * For most methods see the LocalPointerBase base class.
19250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho *
19350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @see LocalPointerBase
19450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @see LocalPointer
19527f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 4.4
19650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */
19750294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_DEFINE_LOCAL_OPEN_POINTER(LocalUTextPointer, UText, utext_close);
19850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
19950294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_NAMESPACE_END
20050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
20150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Open a read-only UText implementation for UTF-8 strings.
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \htmlonly
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Any invalid UTF-8 in the input will be handled in this way:
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a sequence of bytes that has the form of a truncated, but otherwise valid,
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UTF-8 sequence will be replaced by a single unicode replacement character, \uFFFD.
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Any other illegal bytes will each be replaced by a \uFFFD.
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endhtmlonly
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               If non-NULL, must refer to an initialized UText struct, which will then
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               be reset to reference the specified UTF-8 string.
216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s      A UTF-8 string.  Must not be NULL.
217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The length of the UTF-8 string in bytes, or -1 if the string is
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               zero terminated.
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return       A pointer to the UText.  If a pre-allocated UText was provided, it
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               will always be used and returned.
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Open a read-only UText for UChar * string.
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               If non-NULL, must refer to an initialized UText struct, which will then
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               be reset to reference the specified UChar string.
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s      A UChar (UTF-16) string
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length The number of UChars in the input string, or -1 if the string is
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               zero terminated.
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return       A pointer to the UText.  If a pre-allocated UText was provided, it
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               will always be used and returned.
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
24650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if U_SHOW_CPLUSPLUS_API
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Open a writable UText for a non-const UnicodeString.
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut      Pointer to a UText struct.  If NULL, a new UText will be created.
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                 If non-NULL, must refer to an initialized UText struct, which will then
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                 be reset to reference the specified input string.
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s       A UnicodeString.
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return        Pointer to the UText.  If a UText was supplied as input, this
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                 will always be used and returned.
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
260103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliusutext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Open a UText for a const UnicodeString.   The resulting UText will not be writable.
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               If non-NULL, must refer to an initialized UText struct, which will then
268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               be reset to reference the specified input string.
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s      A const UnicodeString to be wrapped.
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return       Pointer to the UText.  If a UText was supplied as input, this
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               will always be used and returned.
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
276103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliusutext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode *status);
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Open a writable UText implementation for an ICU Replaceable object.
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               If non-NULL, must refer to an already existing UText, which will then
283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               be reset to reference the specified replaceable text.
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param rep    A Replaceable text object.
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return       Pointer to the UText.  If a UText was supplied as input, this
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               will always be used and returned.
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see Replaceable
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
292103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliusutext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Open a  UText implementation over an ICU CharacterIterator.
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.
297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               If non-NULL, must refer to an already existing UText, which will then
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               be reset to reference the specified replaceable text.
299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ci     A Character Iterator.
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return       Pointer to the UText.  If a UText was supplied as input, this
302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               will always be used and returned.
303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see Replaceable
304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
30754dcd9b6a06071f647dac967e9e267abb9410720Craig Corneliusutext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *status);
308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Clone a UText.  This is much like opening a UText where the source text is itself
314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  another UText.
315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A deep clone will copy both the UText data structures and the underlying text.
317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  The original and cloned UText will operate completely independently; modifications
318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  made to the text in one will not affect the other.  Text providers are not
319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  required to support deep clones.  The user of clone() must check the status return
320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  and be prepared to handle failures.
321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  The standard UText implementations for UTF8, UChar *, UnicodeString and
323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Replaceable all support deep cloning.
324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  The UText returned from a deep clone will be writable, assuming that the text
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  provider is able to support writing, even if the source UText had been made
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  non-writable by means of UText_freeze().
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A shallow clone replicates only the UText data structures; it does not make
330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  a copy of the underlying text.  Shallow clones can be used as an efficient way to
331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  have multiple iterators active in a single text string that is not being
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  modified.
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A shallow clone operation will not fail, barring truly exceptional conditions such
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  as memory allocation failures.
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Shallow UText clones should be avoided if the UText functions that modify the
338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  text are expected to be used, either on the original or the cloned UText.
339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Any such modifications  can cause unpredictable behavior.  Read Only
340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  shallow clones provide some protection against errors of this type by
341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  disabling text modification via the cloned UText.
342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A shallow clone made with the readOnly parameter == FALSE will preserve the
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  utext_isWritable() state of the source object.  Note, however, that
345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  write operations must be avoided while more than one UText exists that refer
346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  to the same underlying text.
347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A UText and its clone may be safely concurrently accessed by separate threads.
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  This is true for read access only with shallow clones, and for both read and
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  write access with deep clones.
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  It is the responsibility of the Text Provider to ensure that this thread safety
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  constraint is met.
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param dest   A UText struct to be filled in with the result of the clone operation,
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                or NULL if the clone function should heap-allocate a new UText struct.
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                If non-NULL, must refer to an already existing UText, which will then
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                be reset to become the clone.
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param src    The UText to be cloned.
359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param readOnly TRUE to request that the cloned UText have read only access to the
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                underlying text.
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR
364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                will be returned if the text provider is unable to clone the
365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                original text.
366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @return       The newly created clone, or NULL if the clone operation failed.
367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @stable ICU 3.4
368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Compare two UText objects for equality.
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  UTexts are equal if they are iterating over the same text, and
376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *    have the same iteration position within the text.
377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *    If either or both of the parameters are NULL, the comparison is FALSE.
378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param a   The first of the two UTexts to compare.
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param b   The other UText to be compared.
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @return    TRUE if the two UTexts are equal.
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @stable ICU 3.6
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2
385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_equals(const UText *a, const UText *b);
386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*****************************************************************************
389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   Functions to work with the text represeted by a UText wrapper
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *****************************************************************************/
393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Get the length of the text.  Depending on the characteristics
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * of the underlying text representation, this may be expensive.
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @see  utext_isLengthExpensive()
398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @param ut  the text to be accessed.
401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @return the length of the text, expressed in native units.
402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int64_t U_EXPORT2
406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_nativeLength(UText *ut);
407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Return TRUE if calculating the length of the text could be expensive.
410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Finding the length of NUL terminated strings is considered to be expensive.
411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Note that the value of this function may change
413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  as the result of other operations on a UText.
414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Once the length of a string has been discovered, it will no longer
415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  be expensive to report it.
416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed.
418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if determining the length of the text could be time consuming.
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_isLengthExpensive(const UText *ut);
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Returns the code point at the requested index,
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or U_SENTINEL (-1) if it is out of bounds.
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the specified index points to the interior of a multi-unit
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * character - one of the trail bytes of a UTF-8 sequence, for example -
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the complete code point will be returned.
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The iteration position will be set to the start of the returned code point.
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is roughly equivalent to the the sequence
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    utext_setNativeIndex(index);
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    utext_current32();
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (There is a subtle difference if the index is out of bounds by being less than zero -
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * utext_setNativeIndex(negative value) sets the index to zero, after which utext_current()
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will return the char at zero.  utext_char32At(negative index), on the other hand, will
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * return the U_SENTINEL value of -1.)
441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeIndex the native index of the character to be accessed.  If the index points
444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *        to other than the first unit of a multi-unit character, it will be adjusted
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *        to the start of the character.
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the code point at the specified index.
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UChar32 U_EXPORT2
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_char32At(UText *ut, int64_t nativeIndex);
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the code point at the current iteration position,
456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or U_SENTINEL (-1) if the iteration has reached the end of
457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the input text.
458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed.
460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the Unicode code point at the current iterator position.
461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UChar32 U_EXPORT2
464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_current32(UText *ut);
465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the code point at the current iteration position of the UText, and
469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * advance the position to the first index following the character.
470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the position is at the end of the text (the index following
472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the last character, which is also the length of the text),
473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * return U_SENTINEL (-1) and do not advance the index.
474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is a post-increment operation.
476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * An inline macro version of this function, UTEXT_NEXT32(),
478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is available for performance critical use.
479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed.
481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the Unicode code point at the iteration position.
482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTEXT_NEXT32
483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UChar32 U_EXPORT2
486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_next32(UText *ut);
487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Move the iterator position to the character (code point) whose
491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  index precedes the current position, and return that character.
492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  This is a pre-decrement operation.
493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  If the initial position is at the start of the text (index of 0)
495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  return U_SENTINEL (-1), and leave the position unchanged.
496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  An inline macro version of this function, UTEXT_PREVIOUS32(),
498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  is available for performance critical use.
499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  @param ut the text to be accessed.
501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  @return the previous UChar32 code point, or U_SENTINEL (-1)
502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          if the iteration has reached the start of the text.
503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  @see UTEXT_PREVIOUS32
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  @stable ICU 3.4
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UChar32 U_EXPORT2
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_previous32(UText *ut);
508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Set the iteration index and return the code point at that index.
512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Leave the iteration index at the start of the following code point.
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * This function is the most efficient and convenient way to
515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * begin a forward iteration.  The results are identical to the those
516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * from the sequence
517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * \code
518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *    utext_setIndex();
519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *    utext_next32();
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * \endcode
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param ut the text to be accessed.
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param nativeIndex Iteration index, in the native units of the text provider.
524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @return Code point which starts at or before index,
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *         or U_SENTINEL (-1) if it is out of bounds.
526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UChar32 U_EXPORT2
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_next32From(UText *ut, int64_t nativeIndex);
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Set the iteration index, and return the code point preceding the
535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * one specified by the initial index.  Leave the iteration position
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * at the start of the returned code point.
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * This function is the most efficient and convenient way to
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * begin a backwards iteration.
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @param ut the text to be accessed.
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @param nativeIndex Iteration index in the native units of the text provider.
543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @return Code point preceding the one at the initial index,
544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *         or U_SENTINEL (-1) if it is out of bounds.
545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UChar32 U_EXPORT2
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_previous32From(UText *ut, int64_t nativeIndex);
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Get the current iterator position, which can range from 0 to
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * the length of the text.
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * The position is a native index into the input text, in whatever format it
555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * may have (possibly UTF-8 for example), and may not always be the same as
556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * the corresponding UChar (UTF-16) index.
557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * The returned position will always be aligned to a code point boundary.
558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @param ut the text to be accessed.
560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @return the current index position, in the native units of the text provider.
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int64_t U_EXPORT2
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_getNativeIndex(const UText *ut);
565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the current iteration position to the nearest code point
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * boundary at or preceding the specified index.
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The index is in the native units of the original input text.
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the index is out of range, it will be pinned to be within
571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the range of the input text.
572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It will usually be more efficient to begin an iteration
574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * using the functions utext_next32From() or utext_previous32From()
575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * rather than setIndex().
576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Moving the index position to an adjacent character is best done
578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with utext_next32(), utext_previous32() or utext_moveIndex32().
579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Attempting to do direct arithmetic on the index position is
580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * complicated by the fact that the size (in native units) of a
581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * character depends on the underlying representation of the character
582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (UTF-8, UTF-16, UTF-32, arbitrary codepage), and is not
583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * easily knowable.
584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed.
586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeIndex the native unit index of the new iteration position.
587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE void U_EXPORT2
590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_setNativeIndex(UText *ut, int64_t nativeIndex);
591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Move the iterator postion by delta code points.  The number of code points
594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is a signed number; a negative delta will move the iterator backwards,
595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * towards the start of the text.
596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The index is moved by <code>delta</code> code points
598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * forward or backward, but no further backward than to 0 and
599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * no further forward than to utext_nativeLength().
600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The resulting index value will be in between 0 and length, inclusive.
601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed.
603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param delta the signed number of code points to move the iteration position.
604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the position could be moved the requested number of positions while
605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *              staying within the range [0 - text length].
606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2
609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_moveIndex32(UText *ut, int32_t delta);
610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the native index of the character preceeding the current position.
613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the iteration position is already at the start of the text, zero
614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is returned.
615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The value returned is the same as that obtained from the following sequence,
616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * but without the side effect of changing the iteration position.
617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \code
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    UText  *ut = whatever;
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      ...
621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    utext_previous(ut)
622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *    utext_getNativeIndex(ut);
623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \endcode
624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is most useful during forwards iteration, where it will get the
626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   native index of the character most recently returned from utext_next().
627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the text to be accessed
629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the native index of the character preceeding the current index position,
630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         or zero if the current position is at the start of the text.
631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6
632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int64_t U_EXPORT2
634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_getPreviousNativeIndex(UText *ut);
635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Extract text from a UText into a UChar buffer.  The range of text to be extracted
640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is specified in the native indices of the UText provider.  These may not necessarily
641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be UTF-16 indices.
642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The size (number of 16 bit UChars) of the data to be extracted is returned.  The
644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * full number of UChars is returned, even when the extracted text is truncated
645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because the specified buffer size is too small.
646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The extracted string will (if you are a user) / must (if you are a text provider)
648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be NUL-terminated if there is sufficient space in the destination buffer.  This
649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * terminating NUL is not included in the returned length.
650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The iteration index is left at the position following the last extracted character.
652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  ut    the UText from which to extract data.
654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  nativeStart the native index of the first character to extract.\
655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               If the specified index is out of range,
656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               it will be pinned to to be within 0 <= index <= textLength
657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  nativeLimit the native string index of the position following the last
658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               character to extract.  If the specified index is out of range,
659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               it will be pinned to to be within 0 <= index <= textLength.
660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               nativeLimit must be >= nativeStart.
661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  dest  the UChar (UTF-16) buffer into which the extracted text is placed
662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero
663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *               for precomputing the required size.
664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  status receives any error status.
665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         U_BUFFER_OVERFLOW_ERROR: the extracted text was truncated because the
666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         buffer was too small.  Returns number of UChars for preflighting.
667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Number of UChars in the data to be extracted.  Does not include a trailing NUL.
668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_extract(UText *ut,
673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             int64_t nativeStart, int64_t nativeLimit,
674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             UChar *dest, int32_t destCapacity,
675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             UErrorCode *status);
676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
67850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/************************************************************************************
680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  #define inline versions of selected performance-critical text access functions
682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          Caution:  do not use auto increment++ or decrement-- expressions
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    as parameters to these macros.
684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          For most use, where there is no extreme performance constraint, the
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          normal, non-inline functions are a better choice.  The resulting code
687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          will be smaller, and, if the need ever arises, easier to debug.
688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          These are implemented as #defines rather than real functions
690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          because there is no fully portable way to do inline functions in plain C.
691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ************************************************************************************/
693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
694103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
69650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * inline version of utext_current32(), for performance-critical situations.
69750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho *
69850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Get the code point at the current iteration position of the UText.
69950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Returns U_SENTINEL (-1) if the position is at the end of the
70050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * text.
70150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho *
70250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal ICU 4.4 technology preview
70350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */
70450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#define UTEXT_CURRENT32(ut)  \
70550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
70650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    ((ut)->chunkContents)[((ut)->chunkOffset)] : utext_current32(ut))
707103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
70850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
70950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/**
710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * inline version of utext_next32(), for performance-critical situations.
711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the code point at the current iteration position of the UText, and
713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * advance the position to the first index following the character.
714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is a post-increment operation.
715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Returns U_SENTINEL (-1) if the position is at the end of the
716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text.
717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_NEXT32(ut)  \
721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut))
723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * inline version of utext_previous32(), for performance-critical situations.
726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Move the iterator position to the character (code point) whose
728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  index precedes the current position, and return that character.
729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  This is a pre-decrement operation.
730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Returns U_SENTINEL (-1) if the position is at the start of the  text.
731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_PREVIOUS32(ut)  \
735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ((ut)->chunkOffset > 0 && \
736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     (ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \
737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          (ut)->chunkContents[--((ut)->chunkOffset)]  :  utext_previous32(ut))
738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  inline version of utext_getNativeIndex(), for performance-critical situations.
741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Get the current iterator position, which can range from 0 to
743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * the length of the text.
744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * The position is a native index into the input text, in whatever format it
745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * may have (possibly UTF-8 for example), and may not always be the same as
746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * the corresponding UChar (UTF-16) index.
747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * The returned position will always be aligned to a code point boundary.
748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.6
750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_GETNATIVEINDEX(ut)                       \
752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ((ut)->chunkOffset <= (ut)->nativeIndexingLimit?   \
753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        (ut)->chunkNativeStart+(ut)->chunkOffset :     \
754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        (ut)->pFuncs->mapOffsetToNative(ut))
755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  inline version of utext_setNativeIndex(), for performance-critical situations.
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Set the current iteration position to the nearest code point
760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * boundary at or preceding the specified index.
761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * The index is in the native units of the original input text.
762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * If the index is out of range, it will be pinned to be within
763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * the range of the input text.
764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
765b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru  * @stable ICU 3.8
766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_SETNATIVEINDEX(ut, ix)                       \
768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    { int64_t __offset = (ix) - (ut)->chunkNativeStart; \
769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      if (__offset>=0 && __offset<=(int64_t)(ut)->nativeIndexingLimit) { \
770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          (ut)->chunkOffset=(int32_t)__offset; \
771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      } else { \
772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          utext_setNativeIndex((ut), (ix)); } }
773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/************************************************************************************
777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   Functions related to writing or modifying the text.
779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   These will work only with modifiable UTexts.  Attempting to
780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   modify a read-only UText will return an error status.
781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ************************************************************************************/
783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Return TRUE if the text can be written (modified) with utext_replace() or
787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  utext_copy().  For the text to be writable, the text provider must
788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  be of a type that supports writing and the UText must not be frozen.
789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Attempting to modify text when utext_isWriteable() is FALSE will fail -
791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  the text will not be modified, and an error will be returned from the function
792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  that attempted the modification.
793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  ut   the UText to be tested.
795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the text is modifiable.
796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see    utext_freeze()
798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see    utext_replace()
799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see    utext_copy()
800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2
804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_isWritable(const UText *ut);
805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Test whether there is meta data associated with the text.
809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @see Replaceable::hasMetaData()
810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @param ut The UText to be tested
812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @return TRUE if the underlying text includes meta data.
813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2
816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_hasMetaData(const UText *ut);
817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace a range of the original text with a replacement text.
821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Leaves the current iteration position at the position following the
823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  newly inserted replacement text.
824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is only available on UText types that support writing,
826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that is, ones where utext_isWritable() returns TRUE.
827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the
829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string.  Behavior after a replace operation
830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * on a UText is undefined for any other additional UTexts that refer to the
831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * modified string.
832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut               the UText representing the text to be operated on.
834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart      the native index of the start of the region to be replaced
835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit      the native index of the character following the region to be replaced.
836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacementText  pointer to the replacement text
837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacementLength length of the replacement text, or -1 if the text is NUL terminated.
838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status           receives any error status.  Possible errors include
839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                         U_NO_WRITE_PERMISSION
840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The signed number of (native) storage units by which
842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         the length of the text expanded or contracted.
843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_replace(UText *ut,
848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             int64_t nativeStart, int64_t nativeLimit,
849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             const UChar *replacementText, int32_t replacementLength,
850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             UErrorCode *status);
851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy or move a substring from one position to another within the text,
857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * while retaining any metadata associated with the text.
858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is used to duplicate or reorder substrings.
859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The destination index must not overlap the source range.
860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text to be copied or moved is inserted at destIndex;
862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it does not replace or overwrite any existing text.
863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The iteration position is left following the newly inserted text
865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at the destination position.
866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is only available on UText types that support writing,
868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that is, ones where utext_isWritable() returns TRUE.
869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the
871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string.  Behavior after a copy operation
872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * on a UText is undefined in any other additional UTexts that refer to the
873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * modified string.
874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut           The UText representing the text to be operated on.
876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart  The native index of the start of the region to be copied or moved
877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit  The native index of the character position following the region
878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                     to be copied.
879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destIndex    The native destination index to which the source substring is
880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                     copied or moved.
881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param move         If TRUE, then the substring is moved, not copied/duplicated.
882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION
883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE void U_EXPORT2
887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_copy(UText *ut,
888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          int64_t nativeStart, int64_t nativeLimit,
889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          int64_t destIndex,
890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          UBool move,
891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          UErrorCode *status);
892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  <p>
896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Freeze a UText.  This prevents any modification to the underlying text itself
897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  by means of functions operating on this UText.
898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  </p>
899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  <p>
900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Once frozen, a UText can not be unfrozen.  The intent is to ensure
901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  that a the text underlying a frozen UText wrapper cannot be modified via that UText.
902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  </p>
903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  <p>
904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Caution:  freezing a UText will disable changes made via the specific
905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   frozen UText wrapper only; it will not have any effect on the ability to
906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   directly modify the text by bypassing the UText.  Any such backdoor modifications
907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   are always an error while UText access is occuring because the underlying
908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   text can get out of sync with UText's buffering.
909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  </p>
910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param ut  The UText to be frozen.
912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @see   utext_isWritable()
913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @stable ICU 3.6
914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE void U_EXPORT2
916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_freeze(UText *ut);
917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UText provider properties (bit field indexes).
921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UText
923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum {
926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * It is potentially time consuming for the provider to determine the length of the text.
928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Text chunks remain valid and usable until the text object is modified or
933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * deleted, not just until the next time the access() function is called
934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (which is the default).
935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTEXT_PROVIDER_STABLE_CHUNKS = 2,
938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The provider supports modifying the text via the replace() and copy()
940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * functions.
941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see Replaceable
942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTEXT_PROVIDER_WRITABLE = 3,
945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * There is meta data associated with the text.
947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see Replaceable::hasMetaData()
948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTEXT_PROVIDER_HAS_META_DATA = 4,
951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Text provider owns the text storage.
953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  Generally occurs as the result of a deep clone of the UText.
954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  When closing the UText, the associated text must
955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  also be closed/deleted/freed/ whatever is appropriate.
956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     UTEXT_PROVIDER_OWNS_TEXT = 5
959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * Function type declaration for UText.clone().
963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  clone a UText.  Much like opening a UText where the source text is itself
965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  another UText.
966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A deep clone will copy both the UText data structures and the underlying text.
968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  The original and cloned UText will operate completely independently; modifications
969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  made to the text in one will not effect the other.  Text providers are not
970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  required to support deep clones.  The user of clone() must check the status return
971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  and be prepared to handle failures.
972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A shallow clone replicates only the UText data structures; it does not make
974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  a copy of the underlying text.  Shallow clones can be used as an efficient way to
975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  have multiple iterators active in a single text string that is not being
976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  modified.
977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A shallow clone operation must not fail except for truly exceptional conditions such
979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  as memory allocation failures.
980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  A UText and its clone may be safely concurrently accessed by separate threads.
982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  This is true for both shallow and deep clones.
983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  It is the responsibility of the Text Provider to ensure that this thread safety
984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  constraint is met.
985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param dest   A UText struct to be filled in with the result of the clone operation,
988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                or NULL if the clone function should heap-allocate a new UText struct.
989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param src    The UText to be cloned.
990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.
991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR
992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                should be returned if the text provider is unable to clone the
993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                original text.
994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  @return       The newly created clone, or NULL if the clone operation failed.
995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.4
997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef UText * U_CALLCONV
999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
1000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.nativeLength().
1004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText to get the length of.
1006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the length, in the native units of the original text string.
1007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UText
1008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int64_t U_CALLCONV
1011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextNativeLength(UText *ut);
1012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.access().  Get the description of the text chunk
1015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  containing the text at a requested native index.  The UText's iteration
1016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  position will be left at the requested index.  If the index is out
1017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  of bounds, the iteration position will be left at the start or end
1018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  of the string, as appropriate.
1019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Chunks must begin and end on code point boundaries.  A single code point
1021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  comprised of multiple storage units must never span a chunk boundary.
1022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut          the UText being accessed.
1025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeIndex Requested index of the text to be accessed.
1026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param forward     If TRUE, then the returned chunk must contain text
1027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    starting from the index, so that start<=index<limit.
1028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    If FALSE, then the returned chunk must contain text
1029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    before the index, so that start<index<=limit.
1030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return            True if the requested index could be accessed.  The chunk
1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    will contain the requested text.
1032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    False value if a chunk cannot be accessed
1033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    (the requested index is out of bounds).
1034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UText
1036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef UBool U_CALLCONV
1039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextAccess(UText *ut, int64_t nativeIndex, UBool forward);
1040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.extract().
1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Extract text from a UText into a UChar buffer.  The range of text to be extracted
1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is specified in the native indices of the UText provider.  These may not necessarily
1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be UTF-16 indices.
1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The size (number of 16 bit UChars) in the data to be extracted is returned.  The
1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * full amount is returned, even when the specified buffer size is smaller.
1050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>
1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The extracted string will (if you are a user) / must (if you are a text provider)
1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be NUL-terminated if there is sufficient space in the destination buffer.
1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  ut            the UText from which to extract data.
1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  nativeStart   the native index of the first characer to extract.
1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  nativeLimit   the native string index of the position following the last
1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       character to extract.
1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  dest          the UChar (UTF-16) buffer into which the extracted text is placed
1059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero
1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       for precomputing the required size.
1061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param  status        receives any error status.
1062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       If U_BUFFER_OVERFLOW_ERROR: Returns number of UChars for
1063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       preflighting.
1064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Number of UChars in the data.  Does not include a trailing NUL.
1065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV
1069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextExtract(UText *ut,
1070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             int64_t nativeStart, int64_t nativeLimit,
1071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             UChar *dest, int32_t destCapacity,
1072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             UErrorCode *status);
1073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.replace().
1076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace a range of the original text with a replacement text.
1078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Leaves the current iteration position at the position following the
1080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  newly inserted replacement text.
1081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function need only be implemented on UText types that support writing.
1083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the
1085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string.  The function is responsible for updating the
1086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text chunk within the UText to reflect the updated iteration position,
1087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * taking into account any changes to the underlying string's structure caused
1088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by the replace operation.
1089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut               the UText representing the text to be operated on.
1091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart      the index of the start of the region to be replaced
1092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit      the index of the character following the region to be replaced.
1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacementText  pointer to the replacement text
1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacmentLength length of the replacement text in UChars, or -1 if the text is NUL terminated.
1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status           receives any error status.  Possible errors include
1096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                         U_NO_WRITE_PERMISSION
1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The signed number of (native) storage units by which
1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         the length of the text expanded or contracted.
1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV
1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextReplace(UText *ut,
1105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             int64_t nativeStart, int64_t nativeLimit,
1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             const UChar *replacementText, int32_t replacmentLength,
1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             UErrorCode *status);
1108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.copy().
1111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy or move a substring from one position to another within the text,
1113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * while retaining any metadata associated with the text.
1114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is used to duplicate or reorder substrings.
1115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The destination index must not overlap the source range.
1116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text to be copied or moved is inserted at destIndex;
1118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it does not replace or overwrite any existing text.
1119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function need only be implemented for UText types that support writing.
1121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the
1123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string.  The function is responsible for updating the
1124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text chunk within the UText to reflect the updated iteration position,
1125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * taking into account any changes to the underlying string's structure caused
1126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by the replace operation.
1127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut           The UText representing the text to be operated on.
1129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart  The index of the start of the region to be copied or moved
1130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit  The index of the character following the region to be replaced.
1131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeDest   The destination index to which the source substring is copied or moved.
1132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param move         If TRUE, then the substring is moved, not copied/duplicated.
1133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION
1134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef void U_CALLCONV
1138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextCopy(UText *ut,
1139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          int64_t nativeStart, int64_t nativeLimit,
1140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          int64_t nativeDest,
1141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          UBool move,
1142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          UErrorCode *status);
1143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.mapOffsetToNative().
1146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Map from the current UChar offset within the current text chunk to
1147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  the corresponding native index in the original source text.
1148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is required only for text providers that do not use native UTF-16 indexes.
1150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut     the UText.
1152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Absolute (native) index corresponding to chunkOffset in the current chunk.
1153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         The returned native index should always be to a code point boundary.
1154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int64_t U_CALLCONV
1158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextMapOffsetToNative(const UText *ut);
1159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.mapIndexToUTF16().
1162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Map from a native index to a UChar offset within a text chunk.
1163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Behavior is undefined if the native index does not fall within the
1164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   current chunk.
1165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is required only for text providers that do not use native UTF-16 indexes.
1167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut          The UText containing the text chunk.
1169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeIndex Absolute (native) text index, chunk->start<=index<=chunk->limit.
1170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return            Chunk-relative UTF-16 offset corresponding to the specified native
1171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                    index.
1172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV
1176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex);
1177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.utextClose().
1181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A Text Provider close function is only required for provider types that make
1183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  allocations in their open function (or other functions) that must be
1184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  cleaned when the UText is closed.
1185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The allocation of the UText struct itself and any "extra" storage
1187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * associated with the UText is handled by the common UText implementation
1188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and does not require provider specific cleanup in a close function.
1189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Most UText provider implementations do not need to implement this function.
1191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut A UText object to be closed.
1193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef void U_CALLCONV
1197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextClose(UText *ut);
1198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   (public)  Function dispatch table for UText.
1202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *             Conceptually very much like a C++ Virtual Function Table.
1203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *             This struct defines the organization of the table.
1204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *             Each text provider implementation must provide an
1205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *              actual table that is initialized with the appropriate functions
1206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *              for the type of text being handled.
1207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   @stable ICU 3.6
1208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
1209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UTextFuncs {
1210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *   (public)  Function table size, sizeof(UTextFuncs)
1212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             Intended for use should the table grow to accomodate added
1213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             functions in the future, to allow tests for older format
1214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             function tables that do not contain the extensions.
1215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             Fields are placed for optimal alignment on
1217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             32/64/128-bit-pointer machines, by normally grouping together
1218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             4 32-bit fields,
1219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             4 pointers,
1220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             2 64-bit fields
1221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             in sequence.
1222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *   @stable ICU 3.6
1223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t       tableSize;
1225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *   (private)  Alignment padding.
1228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *              Do not use, reserved for use by the UText framework only.
1229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *   @internal
1230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1231c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    int32_t       reserved1, /** @internal */ reserved2, /** @internal */ reserved3;
1232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextClone
1236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextClone
1238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextClone *clone;
1241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) function pointer for UTextLength
1244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * May be expensive to compute!
1245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextLength
1247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextNativeLength *nativeLength;
1250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextAccess.
1253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextAccess
1255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextAccess *access;
1258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextExtract.
1261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextExtract
1263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextExtract *extract;
1266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextReplace.
1269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextReplace
1271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextReplace *replace;
1274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextCopy.
1277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextCopy
1279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextCopy *copy;
1282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextMapOffsetToNative.
1285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextMapOffsetToNative
1287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextMapOffsetToNative *mapOffsetToNative;
1290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextMapNativeIndexToUTF16.
1293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see UTextMapNativeIndexToUTF16
1295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
1298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) Function pointer for UTextClose.
1301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *
1302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @see UTextClose
1303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @stable ICU 3.6
1304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextClose  *close;
1306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (private)  Spare function pointer
1309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal
1310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextClose  *spare1;
131250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
1313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (private)  Spare function pointer
1315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal
1316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextClose  *spare2;
1318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (private)  Spare function pointer
1321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal
1322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTextClose  *spare3;
1324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
1326c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru/**
1327c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru * Function dispatch table for UText
1328c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru * @see UTextFuncs
1329c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru */
1330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UTextFuncs UTextFuncs;
1331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /**
1333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *   UText struct.  Provides the interface between the generic UText access code
1334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                  and the UText provider code that works on specific kinds of
1335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                  text  (UTF-8, noncontiguous UTF-16, whatever.)
1336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
1337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                  Applications that are using predefined types of text providers
1338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                  to pass text data to ICU services will have no need to view the
1339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *                  internals of the UText structs that they open.
1340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *
1341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @stable ICU 3.6
1342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
1343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UText {
1344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *     (private)  Magic.  Used to help detect when UText functions are handed
1346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        invalid or unitialized UText structs.
1347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        utext_openXYZ() functions take an initialized,
1348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        but not necessarily open, UText struct as an
1349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        optional fill-in parameter.  This magic field
1350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        is used to check for that initialization.
1351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        Text provider close functions must NOT clear
1352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        the magic field because that would prevent
1353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                        reuse of the UText struct.
1354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint32_t       magic;
1357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *     (private)  Flags for managing the allocation and freeing of
1361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *                memory associated with this UText.
1362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @internal
1363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t        flags;
1365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  Text provider properties.  This set of flags is maintainted by the
1369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *                             text provider implementation.
1370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  @stable ICU 3.4
1371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         providerProperties;
1373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (public) sizeOfStruct=sizeof(UText)
1376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Allows possible backward compatible extension.
1377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
1379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         sizeOfStruct;
1381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* ------ 16 byte alignment boundary -----------  */
1383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  (protected) Native index of the first character position following
1387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *              the current chunk.
1388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  @stable ICU 3.6
1389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int64_t         chunkNativeLimit;
1391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *   (protected)  Size in bytes of the extra space (pExtra).
1394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @stable ICU 3.4
1395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t        extraSize;
1397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *    (protected) The highest chunk offset where native indexing and
1400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *    chunk (UTF-16) indexing correspond.  For UTF-16 sources, value
1401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *    will be equal to chunkLength.
1402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *
1403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *    @stable ICU 3.6
1404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         nativeIndexingLimit;
1406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* ---- 16 byte alignment boundary------ */
1408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  (protected) Native index of the first character in the text chunk.
1411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @stable ICU 3.6
1412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int64_t         chunkNativeStart;
1414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  (protected) Current iteration position within the text chunk (UTF-16 buffer).
1417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  This is the index to the character that will be returned by utext_next32().
1418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @stable ICU 3.6
1419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         chunkOffset;
1421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  (protected) Length the text chunk (UTF-16 buffer), in UChars.
1424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @stable ICU 3.6
1425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         chunkLength;
1427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* ---- 16  byte alignment boundary-- */
1429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  (protected)  pointer to a chunk of text in UTF-16 format.
1433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  May refer either to original storage of the source of the text, or
1434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  if conversion was required, to a buffer owned by the UText.
1435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  @stable ICU 3.6
1436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const UChar    *chunkContents;
1438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     /**
1440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (public)     Pointer to Dispatch table for accessing functions for this UText.
1441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @stable ICU 3.6
1442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1443c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    const UTextFuncs     *pFuncs;
1444c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
1445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  (protected)  Pointer to additional space requested by the
1447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *               text provider during the utext_open operation.
1448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
1449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void          *pExtra;
1451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (protected) Pointer to string or text-containin object or similar.
1454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This is the source of the text that this UText is wrapping, in a format
1455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  that is known to the text provider functions.
1456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.4
1457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const void   *context;
1459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* --- 16 byte alignment boundary--- */
1461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (protected) Pointer fields available for use by the text provider.
1464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Not used by UText common code.
1465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const void     *p;
1468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (protected) Pointer fields available for use by the text provider.
1470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Not used by UText common code.
1471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const void     *q;
1474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     /**
1475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (protected) Pointer fields available for use by the text provider.
1476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Not used by UText common code.
1477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.6
1478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const void     *r;
1480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  Private field reserved for future use by the UText framework
1483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *     itself.  This is not to be touched by the text providers.
1484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal ICU 3.4
1485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void           *privP;
1487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* --- 16 byte alignment boundary--- */
1490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (protected) Integer field reserved for use by the text provider.
1494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * Not used by the UText framework, or by the client (user) of the UText.
1495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @stable ICU 3.4
1496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int64_t         a;
1498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (protected) Integer field reserved for use by the text provider.
1501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * Not used by the UText framework, or by the client (user) of the UText.
1502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @stable ICU 3.4
1503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         b;
1505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * (protected) Integer field reserved for use by the text provider.
1508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * Not used by the UText framework, or by the client (user) of the UText.
1509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @stable ICU 3.4
1510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         c;
1512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /*  ---- 16 byte alignment boundary---- */
1514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  Private field reserved for future use by the UText framework
1518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *     itself.  This is not to be touched by the text providers.
1519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal ICU 3.4
1520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int64_t         privA;
1522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  Private field reserved for future use by the UText framework
1524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *     itself.  This is not to be touched by the text providers.
1525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal ICU 3.4
1526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         privB;
1528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
1529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *  Private field reserved for future use by the UText framework
1530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      *     itself.  This is not to be touched by the text providers.
1531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      * @internal ICU 3.4
1532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      */
1533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         privC;
1534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
1535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  Common function for use by Text Provider implementations to allocate and/or initialize
1539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  a new UText struct.  To be called in the implementation of utext_open() functions.
1540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  If the supplied UText parameter is null, a new UText struct will be allocated on the heap.
1541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  If the supplied UText is already open, the provider's close function will be called
1542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  so that the struct can be reused by the open that is in progress.
1543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut   pointer to a UText struct to be re-used, or null if a new UText
1545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *             should be allocated.
1546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param extraSpace The amount of additional space to be allocated as part
1547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *             of this UText, for use by types of providers that require
1548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *             additional storage.
1549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here.
1550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return pointer to the UText, allocated if necessary, with extra space set up if requested.
1551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4
1552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2
1554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
1555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1556103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
1557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  * @internal
1559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Value used to help identify correctly initialized UText structs.
1560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  *  Note:  must be publicly visible so that UTEXT_INITIALIZER can access it.
1561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  */
1562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum {
1563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UTEXT_MAGIC = 0x345ad82c
1564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
1565103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
1566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * initializer to be used with local (stack) instances of a UText
1569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  struct.  UText structs must be initialized before passing
1570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  them to one of the utext_open functions.
1571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6
1573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_INITIALIZER {                                        \
1575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  UTEXT_MAGIC,          /* magic                */ \
1576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* flags                */ \
1577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* providerProps        */ \
1578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  sizeof(UText),        /* sizeOfStruct         */ \
1579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* chunkNativeLimit     */ \
1580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* extraSize            */ \
1581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* nativeIndexingLimit  */ \
1582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* chunkNativeStart     */ \
1583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* chunkOffset          */ \
1584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0,                    /* chunkLength          */ \
1585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  NULL,                 /* chunkContents        */ \
1586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  NULL,                 /* pFuncs               */ \
1587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  NULL,                 /* pExtra               */ \
1588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  NULL,                 /* context              */ \
1589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  NULL, NULL, NULL,     /* p, q, r              */ \
1590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  NULL,                 /* privP                */ \
1591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0, 0, 0,              /* a, b, c              */ \
1592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  0, 0, 0               /* privA,B,C,           */ \
1593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                  }
1594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_END
1597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1601