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