1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru******************************************************************************* 3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho* Copyright (C) 2004-2010, 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 260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_openUnicodeString(UText *ut, U_NAMESPACE_QUALIFIER 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 276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_openConstUnicodeString(UText *ut, const U_NAMESPACE_QUALIFIER 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 292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_openReplaceable(UText *ut, U_NAMESPACE_QUALIFIER 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 307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_openCharacterIterator(UText *ut, U_NAMESPACE_QUALIFIER CharacterIterator *ic, 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/** 67950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Compare two UTexts (binary order). The comparison begins at each source text's 68050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * iteration position. The iteration position of each UText will be left following 68150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the last character compared. 68250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 68350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The comparison is done in code point order; unlike u_strCompare, you 68450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * cannot choose to use code unit order. This is because the characters 68550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * in a UText are accessed one code point at a time, and may not be from a UTF-16 68650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * context. 68750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 68850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * This functions works with strings of different explicitly specified lengths 68950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. 69050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * A length argument of -1 signifies that as much of the string should be used as 69150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * is necessary to compare with the other string. If both length arguments are -1, 69250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the entire remaining portionss of both strings are used. 69350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 69450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s1 First source string. 69550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param length1 Length of first source string in UTF-32 code points. 69650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 69750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s2 Second source string. 69850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param length2 Length of second source string in UTF-32 code points. 69950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 70050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return <0 or 0 or >0 as usual for string comparisons 70150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 70250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal ICU 4.4 technology preview 70350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 70450294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_INTERNAL int32_t U_EXPORT2 70550294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoutext_compare(UText *s1, int32_t length1, 70650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UText *s2, int32_t length2); 70750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 70850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/** 70950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Compare two UTexts (binary order). The comparison begins at each source text's 71050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * iteration position. The iteration position of each UText will be left following 71150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the last character compared. This method differs from utext_compare in that 71250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * it accepts native limits rather than lengths for each string. 71350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 71450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The comparison is done in code point order; unlike u_strCompare, you 71550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * cannot choose to use code unit order. This is because the characters 71650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * in a UText are accessed one code point at a time, and may not be from a UTF-16 71750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * context. 71850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 71950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * This functions works with strings of different explicitly specified lengths 72050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. 72150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * A limit argument of -1 signifies that as much of the string should be used as 72250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * is necessary to compare with the other string. If both limit arguments are -1, 72350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the entire remaining portionss of both strings are used. 72450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 72550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s1 First source string. 72650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param limit1 Native index of the last character in the first source string to be considered. 72750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 72850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s2 Second source string. 72950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param limit2 Native index of the last character in the second source string to be considered. 73050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 73150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return <0 or 0 or >0 as usual for string comparisons 73250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 73350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal ICU 4.4 technology preview 73450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 73550294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_INTERNAL int32_t U_EXPORT2 73650294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoutext_compareNativeLimit(UText *s1, int64_t limit1, 73750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UText *s2, int64_t limit2); 73850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 73950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/** 74050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Compare two UTexts case-insensitively using full case folding. The comparison 74150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * begins at each source text's iteration position. The iteration position of each 74250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * UText will be left following the last character compared. 74350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 74450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The comparison is done in code point order; this is because the characters 74550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * in a UText are accessed one code point at a time, and may not be from a UTF-16 74650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * context. 74750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 74850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * This functions works with strings of different explicitly specified lengths 74950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. 75050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * A length argument of -1 signifies that as much of the string should be used as 75150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * is necessary to compare with the other string. If both length arguments are -1, 75250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the entire remaining portionss of both strings are used. 75350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 75450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s1 First source string. 75550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param length1 Length of first source string in UTF-32 code points. 75650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 75750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s2 Second source string. 75850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param length2 Length of second source string in UTF-32 code points. 75950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 76050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param options A bit set of options: 76150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 76250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Comparison in code point order with default case folding. 76350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 76450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 76550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 76650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param pErrorCode Must be a valid pointer to an error code value, 76750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * which must not indicate a failure before the function call. 76850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 76950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return <0 or 0 or >0 as usual for string comparisons 77050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 77150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal ICU 4.4 technology preview 77250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 77350294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_INTERNAL int32_t U_EXPORT2 77450294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoutext_caseCompare(UText *s1, int32_t length1, 77550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UText *s2, int32_t length2, 77650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho uint32_t options, UErrorCode *pErrorCode); 77750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 77850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/** 77950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Compare two UTexts case-insensitively using full case folding. The comparison 78050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * begins at each source text's iteration position. The iteration position of each 78150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * UText will be left following the last character compared. This method differs from 78250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * utext_caseCompare in that it accepts native limits rather than lengths for each 78350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * string. 78450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 78550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * The comparison is done in code point order; this is because the characters 78650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * in a UText are accessed one code point at a time, and may not be from a UTF-16 78750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * context. 78850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 78950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * This functions works with strings of different explicitly specified lengths 79050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. 79150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * A limit argument of -1 signifies that as much of the string should be used as 79250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * is necessary to compare with the other string. If both length arguments are -1, 79350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * the entire remaining portionss of both strings are used. 79450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 79550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s1 First source string. 79650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param limit1 Native index of the last character in the first source string to be considered. 79750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 79850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param s2 Second source string. 79950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param limit2 Native index of the last character in the second source string to be considered. 80050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 80150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param options A bit set of options: 80250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 80350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Comparison in code point order with default case folding. 80450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 80550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 80650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 80750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @param pErrorCode Must be a valid pointer to an error code value, 80850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * which must not indicate a failure before the function call. 80950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 81050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @return <0 or 0 or >0 as usual for string comparisons 81150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 81250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal ICU 4.4 technology preview 81350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 81450294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoU_INTERNAL int32_t U_EXPORT2 81550294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoutext_caseCompareNativeLimit(UText *s1, int64_t limit1, 81650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho UText *s2, int64_t limit2, 81750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho uint32_t options, UErrorCode *pErrorCode); 81850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 81950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/************************************************************************************ 821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * #define inline versions of selected performance-critical text access functions 823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Caution: do not use auto increment++ or decrement-- expressions 824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as parameters to these macros. 825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For most use, where there is no extreme performance constraint, the 827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * normal, non-inline functions are a better choice. The resulting code 828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be smaller, and, if the need ever arises, easier to debug. 829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * These are implemented as #defines rather than real functions 831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * because there is no fully portable way to do inline functions in plain C. 832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ************************************************************************************/ 834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 83650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * inline version of utext_current32(), for performance-critical situations. 83750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 83850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Get the code point at the current iteration position of the UText. 83950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Returns U_SENTINEL (-1) if the position is at the end of the 84050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * text. 84150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * 84250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal ICU 4.4 technology preview 84350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 84450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#define UTEXT_CURRENT32(ut) \ 84550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \ 84650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho ((ut)->chunkContents)[((ut)->chunkOffset)] : utext_current32(ut)) 84750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 84850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/** 849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * inline version of utext_next32(), for performance-critical situations. 850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the code point at the current iteration position of the UText, and 852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * advance the position to the first index following the character. 853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is a post-increment operation. 854b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Returns U_SENTINEL (-1) if the position is at the end of the 855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text. 856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 857b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 858b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 859b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_NEXT32(ut) \ 860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \ 861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut)) 862b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 863b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 864b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * inline version of utext_previous32(), for performance-critical situations. 865b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 866b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Move the iterator position to the character (code point) whose 867b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * index precedes the current position, and return that character. 868b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is a pre-decrement operation. 869b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Returns U_SENTINEL (-1) if the position is at the start of the text. 870b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_PREVIOUS32(ut) \ 874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ((ut)->chunkOffset > 0 && \ 875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru (ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \ 876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru (ut)->chunkContents[--((ut)->chunkOffset)] : utext_previous32(ut)) 877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * inline version of utext_getNativeIndex(), for performance-critical situations. 880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the current iterator position, which can range from 0 to 882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the length of the text. 883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The position is a native index into the input text, in whatever format it 884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * may have (possibly UTF-8 for example), and may not always be the same as 885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the corresponding UChar (UTF-16) index. 886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The returned position will always be aligned to a code point boundary. 887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_GETNATIVEINDEX(ut) \ 891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ((ut)->chunkOffset <= (ut)->nativeIndexingLimit? \ 892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru (ut)->chunkNativeStart+(ut)->chunkOffset : \ 893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru (ut)->pFuncs->mapOffsetToNative(ut)) 894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * inline version of utext_setNativeIndex(), for performance-critical situations. 897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Set the current iteration position to the nearest code point 899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * boundary at or preceding the specified index. 900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The index is in the native units of the original input text. 901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the index is out of range, it will be pinned to be within 902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the range of the input text. 903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 904b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru * @stable ICU 3.8 905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_SETNATIVEINDEX(ut, ix) \ 907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru { int64_t __offset = (ix) - (ut)->chunkNativeStart; \ 908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if (__offset>=0 && __offset<=(int64_t)(ut)->nativeIndexingLimit) { \ 909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru (ut)->chunkOffset=(int32_t)__offset; \ 910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { \ 911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru utext_setNativeIndex((ut), (ix)); } } 912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/************************************************************************************ 916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Functions related to writing or modifying the text. 918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * These will work only with modifiable UTexts. Attempting to 919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * modify a read-only UText will return an error status. 920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ************************************************************************************/ 922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Return TRUE if the text can be written (modified) with utext_replace() or 926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * utext_copy(). For the text to be writable, the text provider must 927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be of a type that supports writing and the UText must not be frozen. 928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Attempting to modify text when utext_isWriteable() is FALSE will fail - 930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the text will not be modified, and an error will be returned from the function 931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that attempted the modification. 932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText to be tested. 934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the text is modifiable. 935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see utext_freeze() 937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see utext_replace() 938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see utext_copy() 939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2 943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_isWritable(const UText *ut); 944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Test whether there is meta data associated with the text. 948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see Replaceable::hasMetaData() 949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut The UText to be tested 951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the underlying text includes meta data. 952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UBool U_EXPORT2 955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_hasMetaData(const UText *ut); 956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace a range of the original text with a replacement text. 960b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 961b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Leaves the current iteration position at the position following the 962b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * newly inserted replacement text. 963b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 964b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is only available on UText types that support writing, 965b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that is, ones where utext_isWritable() returns TRUE. 966b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 967b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the 968b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string. Behavior after a replace operation 969b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * on a UText is undefined for any other additional UTexts that refer to the 970b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * modified string. 971b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 972b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText representing the text to be operated on. 973b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart the native index of the start of the region to be replaced 974b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit the native index of the character following the region to be replaced. 975b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacementText pointer to the replacement text 976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacementLength length of the replacement text, or -1 if the text is NUL terminated. 977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status receives any error status. Possible errors include 978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_NO_WRITE_PERMISSION 979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The signed number of (native) storage units by which 981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the length of the text expanded or contracted. 982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_replace(UText *ut, 987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t nativeStart, int64_t nativeLimit, 988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *replacementText, int32_t replacementLength, 989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *status); 990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy or move a substring from one position to another within the text, 996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * while retaining any metadata associated with the text. 997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is used to duplicate or reorder substrings. 998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The destination index must not overlap the source range. 999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text to be copied or moved is inserted at destIndex; 1001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it does not replace or overwrite any existing text. 1002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The iteration position is left following the newly inserted text 1004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * at the destination position. 1005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is only available on UText types that support writing, 1007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that is, ones where utext_isWritable() returns TRUE. 1008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the 1010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string. Behavior after a copy operation 1011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * on a UText is undefined in any other additional UTexts that refer to the 1012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * modified string. 1013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut The UText representing the text to be operated on. 1015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart The native index of the start of the region to be copied or moved 1016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit The native index of the character position following the region 1017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to be copied. 1018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destIndex The native destination index to which the source substring is 1019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * copied or moved. 1020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param move If TRUE, then the substring is moved, not copied/duplicated. 1021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION 1022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE void U_EXPORT2 1026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_copy(UText *ut, 1027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t nativeStart, int64_t nativeLimit, 1028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t destIndex, 1029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool move, 1030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *status); 1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p> 1035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Freeze a UText. This prevents any modification to the underlying text itself 1036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by means of functions operating on this UText. 1037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </p> 1038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p> 1039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Once frozen, a UText can not be unfrozen. The intent is to ensure 1040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that a the text underlying a frozen UText wrapper cannot be modified via that UText. 1041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </p> 1042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p> 1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Caution: freezing a UText will disable changes made via the specific 1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * frozen UText wrapper only; it will not have any effect on the ability to 1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * directly modify the text by bypassing the UText. Any such backdoor modifications 1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are always an error while UText access is occuring because the underlying 1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text can get out of sync with UText's buffering. 1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * </p> 1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut The UText to be frozen. 1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see utext_isWritable() 1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE void U_EXPORT2 1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_freeze(UText *ut); 1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UText provider properties (bit field indexes). 1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UText 1062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 1065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It is potentially time consuming for the provider to determine the length of the text. 1067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1, 1070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Text chunks remain valid and usable until the text object is modified or 1072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * deleted, not just until the next time the access() function is called 1073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (which is the default). 1074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_PROVIDER_STABLE_CHUNKS = 2, 1077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The provider supports modifying the text via the replace() and copy() 1079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * functions. 1080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see Replaceable 1081b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_PROVIDER_WRITABLE = 3, 1084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * There is meta data associated with the text. 1086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see Replaceable::hasMetaData() 1087b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1088b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_PROVIDER_HAS_META_DATA = 4, 1090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Text provider owns the text storage. 1092b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Generally occurs as the result of a deep clone of the UText. 1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When closing the UText, the associated text must 1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * also be closed/deleted/freed/ whatever is appropriate. 1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_PROVIDER_OWNS_TEXT = 5 1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.clone(). 1102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * clone a UText. Much like opening a UText where the source text is itself 1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * another UText. 1105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A deep clone will copy both the UText data structures and the underlying text. 1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The original and cloned UText will operate completely independently; modifications 1108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * made to the text in one will not effect the other. Text providers are not 1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * required to support deep clones. The user of clone() must check the status return 1110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and be prepared to handle failures. 1111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A shallow clone replicates only the UText data structures; it does not make 1113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a copy of the underlying text. Shallow clones can be used as an efficient way to 1114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * have multiple iterators active in a single text string that is not being 1115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * modified. 1116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A shallow clone operation must not fail except for truly exceptional conditions such 1118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * as memory allocation failures. 1119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A UText and its clone may be safely concurrently accessed by separate threads. 1121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is true for both shallow and deep clones. 1122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It is the responsibility of the Text Provider to ensure that this thread safety 1123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * constraint is met. 1124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest A UText struct to be filled in with the result of the clone operation, 1127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or NULL if the clone function should heap-allocate a new UText struct. 1128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src The UText to be cloned. 1129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param deep TRUE to request a deep clone, FALSE for a shallow clone. 1130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR 1131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * should be returned if the text provider is unable to clone the 1132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * original text. 1133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The newly created clone, or NULL if the clone operation failed. 1134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef UText * U_CALLCONV 1138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status); 1139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.nativeLength(). 1143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText to get the length of. 1145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return the length, in the native units of the original text string. 1146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UText 1147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int64_t U_CALLCONV 1150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextNativeLength(UText *ut); 1151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.access(). Get the description of the text chunk 1154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * containing the text at a requested native index. The UText's iteration 1155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * position will be left at the requested index. If the index is out 1156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of bounds, the iteration position will be left at the start or end 1157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of the string, as appropriate. 1158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Chunks must begin and end on code point boundaries. A single code point 1160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * comprised of multiple storage units must never span a chunk boundary. 1161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText being accessed. 1164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeIndex Requested index of the text to be accessed. 1165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param forward If TRUE, then the returned chunk must contain text 1166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * starting from the index, so that start<=index<limit. 1167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If FALSE, then the returned chunk must contain text 1168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * before the index, so that start<index<=limit. 1169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return True if the requested index could be accessed. The chunk 1170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will contain the requested text. 1171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * False value if a chunk cannot be accessed 1172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (the requested index is out of bounds). 1173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UText 1175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef UBool U_CALLCONV 1178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextAccess(UText *ut, int64_t nativeIndex, UBool forward); 1179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.extract(). 1182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Extract text from a UText into a UChar buffer. The range of text to be extracted 1184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is specified in the native indices of the UText provider. These may not necessarily 1185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be UTF-16 indices. 1186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p> 1187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The size (number of 16 bit UChars) in the data to be extracted is returned. The 1188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * full amount is returned, even when the specified buffer size is smaller. 1189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p> 1190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The extracted string will (if you are a user) / must (if you are a text provider) 1191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * be NUL-terminated if there is sufficient space in the destination buffer. 1192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText from which to extract data. 1194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart the native index of the first characer to extract. 1195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit the native string index of the position following the last 1196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * character to extract. 1197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest the UChar (UTF-16) buffer into which the extracted text is placed 1198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity The size, in UChars, of the destination buffer. May be zero 1199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * for precomputing the required size. 1200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status receives any error status. 1201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If U_BUFFER_OVERFLOW_ERROR: Returns number of UChars for 1202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * preflighting. 1203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Number of UChars in the data. Does not include a trailing NUL. 1204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV 1208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextExtract(UText *ut, 1209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t nativeStart, int64_t nativeLimit, 1210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dest, int32_t destCapacity, 1211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *status); 1212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.replace(). 1215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Replace a range of the original text with a replacement text. 1217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Leaves the current iteration position at the position following the 1219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * newly inserted replacement text. 1220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function need only be implemented on UText types that support writing. 1222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the 1224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string. The function is responsible for updating the 1225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text chunk within the UText to reflect the updated iteration position, 1226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * taking into account any changes to the underlying string's structure caused 1227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by the replace operation. 1228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText representing the text to be operated on. 1230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart the index of the start of the region to be replaced 1231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit the index of the character following the region to be replaced. 1232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacementText pointer to the replacement text 1233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param replacmentLength length of the replacement text in UChars, or -1 if the text is NUL terminated. 1234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status receives any error status. Possible errors include 1235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_NO_WRITE_PERMISSION 1236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The signed number of (native) storage units by which 1238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the length of the text expanded or contracted. 1239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV 1243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextReplace(UText *ut, 1244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t nativeStart, int64_t nativeLimit, 1245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *replacementText, int32_t replacmentLength, 1246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *status); 1247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.copy(). 1250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Copy or move a substring from one position to another within the text, 1252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * while retaining any metadata associated with the text. 1253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is used to duplicate or reorder substrings. 1254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The destination index must not overlap the source range. 1255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The text to be copied or moved is inserted at destIndex; 1257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * it does not replace or overwrite any existing text. 1258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function need only be implemented for UText types that support writing. 1260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * When using this function, there should be only a single UText opened onto the 1262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * underlying native text string. The function is responsible for updating the 1263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text chunk within the UText to reflect the updated iteration position, 1264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * taking into account any changes to the underlying string's structure caused 1265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * by the replace operation. 1266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut The UText representing the text to be operated on. 1268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeStart The index of the start of the region to be copied or moved 1269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeLimit The index of the character following the region to be replaced. 1270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeDest The destination index to which the source substring is copied or moved. 1271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param move If TRUE, then the substring is moved, not copied/duplicated. 1272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION 1273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef void U_CALLCONV 1277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextCopy(UText *ut, 1278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t nativeStart, int64_t nativeLimit, 1279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t nativeDest, 1280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool move, 1281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *status); 1282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.mapOffsetToNative(). 1285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Map from the current UChar offset within the current text chunk to 1286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the corresponding native index in the original source text. 1287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is required only for text providers that do not use native UTF-16 indexes. 1289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut the UText. 1291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Absolute (native) index corresponding to chunkOffset in the current chunk. 1292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The returned native index should always be to a code point boundary. 1293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int64_t U_CALLCONV 1297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextMapOffsetToNative(const UText *ut); 1298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.mapIndexToUTF16(). 1301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Map from a native index to a UChar offset within a text chunk. 1302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Behavior is undefined if the native index does not fall within the 1303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * current chunk. 1304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function is required only for text providers that do not use native UTF-16 indexes. 1306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut The UText containing the text chunk. 1308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param nativeIndex Absolute (native) text index, chunk->start<=index<=chunk->limit. 1309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Chunk-relative UTF-16 offset corresponding to the specified native 1310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * index. 1311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV 1315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex); 1316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Function type declaration for UText.utextClose(). 1320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * A Text Provider close function is only required for provider types that make 1322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * allocations in their open function (or other functions) that must be 1323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * cleaned when the UText is closed. 1324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The allocation of the UText struct itself and any "extra" storage 1326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * associated with the UText is handled by the common UText implementation 1327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and does not require provider specific cleanup in a close function. 1328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Most UText provider implementations do not need to implement this function. 1330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut A UText object to be closed. 1332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef void U_CALLCONV 1336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUTextClose(UText *ut); 1337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function dispatch table for UText. 1341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Conceptually very much like a C++ Virtual Function Table. 1342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This struct defines the organization of the table. 1343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Each text provider implementation must provide an 1344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * actual table that is initialized with the appropriate functions 1345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * for the type of text being handled. 1346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UTextFuncs { 1349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function table size, sizeof(UTextFuncs) 1351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Intended for use should the table grow to accomodate added 1352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * functions in the future, to allow tests for older format 1353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * function tables that do not contain the extensions. 1354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Fields are placed for optimal alignment on 1356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 32/64/128-bit-pointer machines, by normally grouping together 1357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 4 32-bit fields, 1358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 4 pointers, 1359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 2 64-bit fields 1360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in sequence. 1361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t tableSize; 1364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (private) Alignment padding. 1367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Do not use, reserved for use by the UText framework only. 1368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1370c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru int32_t reserved1, /** @internal */ reserved2, /** @internal */ reserved3; 1371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextClone 1375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextClone 1377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextClone *clone; 1380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) function pointer for UTextLength 1383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * May be expensive to compute! 1384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextLength 1386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextNativeLength *nativeLength; 1389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextAccess. 1392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextAccess 1394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextAccess *access; 1397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextExtract. 1400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextExtract 1402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextExtract *extract; 1405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextReplace. 1408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextReplace 1410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextReplace *replace; 1413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextCopy. 1416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextCopy 1418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextCopy *copy; 1421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextMapOffsetToNative. 1424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextMapOffsetToNative 1426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextMapOffsetToNative *mapOffsetToNative; 1429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextMapNativeIndexToUTF16. 1432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextMapNativeIndexToUTF16 1434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16; 1437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Function pointer for UTextClose. 1440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UTextClose 1442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextClose *close; 1445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (private) Spare function pointer 1448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextClose *spare1; 145150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 1452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (private) Spare function pointer 1454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextClose *spare2; 1457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (private) Spare function pointer 1460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTextClose *spare3; 1463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 1465c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru/** 1466c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru * Function dispatch table for UText 1467c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru * @see UTextFuncs 1468c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru */ 1469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UTextFuncs UTextFuncs; 1470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UText struct. Provides the interface between the generic UText access code 1473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and the UText provider code that works on specific kinds of 1474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text (UTF-8, noncontiguous UTF-16, whatever.) 1475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Applications that are using predefined types of text providers 1477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to pass text data to ICU services will have no need to view the 1478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * internals of the UText structs that they open. 1479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UText { 1483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (private) Magic. Used to help detect when UText functions are handed 1485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * invalid or unitialized UText structs. 1486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * utext_openXYZ() functions take an initialized, 1487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * but not necessarily open, UText struct as an 1488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * optional fill-in parameter. This magic field 1489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * is used to check for that initialization. 1490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Text provider close functions must NOT clear 1491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the magic field because that would prevent 1492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * reuse of the UText struct. 1493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t magic; 1496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (private) Flags for managing the allocation and freeing of 1500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * memory associated with this UText. 1501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t flags; 1504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Text provider properties. This set of flags is maintainted by the 1508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text provider implementation. 1509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t providerProperties; 1512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) sizeOfStruct=sizeof(UText) 1515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Allows possible backward compatible extension. 1516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t sizeOfStruct; 1520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* ------ 16 byte alignment boundary ----------- */ 1522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Native index of the first character position following 1526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the current chunk. 1527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t chunkNativeLimit; 1530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Size in bytes of the extra space (pExtra). 1533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t extraSize; 1536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) The highest chunk offset where native indexing and 1539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * chunk (UTF-16) indexing correspond. For UTF-16 sources, value 1540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * will be equal to chunkLength. 1541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t nativeIndexingLimit; 1545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* ---- 16 byte alignment boundary------ */ 1547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Native index of the first character in the text chunk. 1550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t chunkNativeStart; 1553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Current iteration position within the text chunk (UTF-16 buffer). 1556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is the index to the character that will be returned by utext_next32(). 1557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t chunkOffset; 1560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Length the text chunk (UTF-16 buffer), in UChars. 1563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t chunkLength; 1566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* ---- 16 byte alignment boundary-- */ 1568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) pointer to a chunk of text in UTF-16 format. 1572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * May refer either to original storage of the source of the text, or 1573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if conversion was required, to a buffer owned by the UText. 1574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *chunkContents; 1577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (public) Pointer to Dispatch table for accessing functions for this UText. 1580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1582c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru const UTextFuncs *pFuncs; 1583c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 1584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Pointer to additional space requested by the 1586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * text provider during the utext_open operation. 1587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void *pExtra; 1590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Pointer to string or text-containin object or similar. 1593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is the source of the text that this UText is wrapping, in a format 1594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that is known to the text provider functions. 1595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const void *context; 1598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* --- 16 byte alignment boundary--- */ 1600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Pointer fields available for use by the text provider. 1603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Not used by UText common code. 1604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const void *p; 1607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Pointer fields available for use by the text provider. 1609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Not used by UText common code. 1610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const void *q; 1613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Pointer fields available for use by the text provider. 1615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Not used by UText common code. 1616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const void *r; 1619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Private field reserved for future use by the UText framework 1622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * itself. This is not to be touched by the text providers. 1623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal ICU 3.4 1624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void *privP; 1626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* --- 16 byte alignment boundary--- */ 1629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Integer field reserved for use by the text provider. 1633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Not used by the UText framework, or by the client (user) of the UText. 1634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t a; 1637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Integer field reserved for use by the text provider. 1640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Not used by the UText framework, or by the client (user) of the UText. 1641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t b; 1644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (protected) Integer field reserved for use by the text provider. 1647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Not used by the UText framework, or by the client (user) of the UText. 1648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t c; 1651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /* ---- 16 byte alignment boundary---- */ 1653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Private field reserved for future use by the UText framework 1657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * itself. This is not to be touched by the text providers. 1658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal ICU 3.4 1659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int64_t privA; 1661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Private field reserved for future use by the UText framework 1663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * itself. This is not to be touched by the text providers. 1664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal ICU 3.4 1665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t privB; 1667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 1668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Private field reserved for future use by the UText framework 1669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * itself. This is not to be touched by the text providers. 1670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal ICU 3.4 1671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t privC; 1673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 1674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Common function for use by Text Provider implementations to allocate and/or initialize 1678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * a new UText struct. To be called in the implementation of utext_open() functions. 1679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the supplied UText parameter is null, a new UText struct will be allocated on the heap. 1680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the supplied UText is already open, the provider's close function will be called 1681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * so that the struct can be reused by the open that is in progress. 1682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param ut pointer to a UText struct to be re-used, or null if a new UText 1684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * should be allocated. 1685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param extraSpace The amount of additional space to be allocated as part 1686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of this UText, for use by types of providers that require 1687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * additional storage. 1688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status Errors are returned here. 1689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return pointer to the UText, allocated if necessary, with extra space set up if requested. 1690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.4 1691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE UText * U_EXPORT2 1693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruutext_setup(UText *ut, int32_t extraSpace, UErrorCode *status); 1694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 1697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Value used to help identify correctly initialized UText structs. 1698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Note: must be publicly visible so that UTEXT_INITIALIZER can access it. 1699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 1701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_MAGIC = 0x345ad82c 1702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 1703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 1705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * initializer to be used with local (stack) instances of a UText 1706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * struct. UText structs must be initialized before passing 1707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * them to one of the utext_open functions. 1708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 1709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 3.6 1710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 1711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UTEXT_INITIALIZER { \ 1712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UTEXT_MAGIC, /* magic */ \ 1713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* flags */ \ 1714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* providerProps */ \ 1715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru sizeof(UText), /* sizeOfStruct */ \ 1716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* chunkNativeLimit */ \ 1717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* extraSize */ \ 1718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* nativeIndexingLimit */ \ 1719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* chunkNativeStart */ \ 1720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* chunkOffset */ \ 1721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, /* chunkLength */ \ 1722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru NULL, /* chunkContents */ \ 1723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru NULL, /* pFuncs */ \ 1724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru NULL, /* pExtra */ \ 1725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru NULL, /* context */ \ 1726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru NULL, NULL, NULL, /* p, q, r */ \ 1727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru NULL, /* privP */ \ 1728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, 0, 0, /* a, b, c */ \ 1729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 0, 0, 0 /* privA,B,C, */ \ 1730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 1731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_END 1734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 1737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 1738