00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __UTEXT_H__
00018 #define __UTEXT_H__
00019
00109 #include "unicode/utypes.h"
00110 #ifdef XP_CPLUSPLUS
00111 #include "unicode/rep.h"
00112 #include "unicode/unistr.h"
00113 #endif
00114
00115 #ifndef U_HIDE_DRAFT_API
00116
00117 U_CDECL_BEGIN
00118
00119 struct UText;
00120 typedef struct UText UText;
00122 struct UTextChunk;
00123 typedef struct UTextChunk UTextChunk;
00127
00128
00129
00130
00131
00132
00133
00155 U_DRAFT UText * U_EXPORT2
00156 utext_close(UText *ut);
00157
00158
00180 U_DRAFT UText * U_EXPORT2
00181 utext_openUTF8(UText *ut, const char *s, int32_t length, UErrorCode *status);
00182
00183
00198 U_DRAFT UText * U_EXPORT2
00199 utext_openUChars(UText *ut, const UChar *s, int32_t length, UErrorCode *status);
00200
00201
00202 #ifdef XP_CPLUSPLUS
00203
00215 U_DRAFT UText * U_EXPORT2
00216 utext_openUnicodeString(UText *ut, UnicodeString *s, UErrorCode *status);
00217
00218
00231 U_DRAFT UText * U_EXPORT2
00232 utext_openConstUnicodeString(UText *ut, const UnicodeString *s, UErrorCode *status);
00233
00234
00247 U_DRAFT UText * U_EXPORT2
00248 utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status);
00249
00250 #endif
00251
00252
00286 U_DRAFT UText * U_EXPORT2
00287 utext_clone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
00288
00289
00290
00291
00292
00293
00294
00295
00307 U_DRAFT int32_t U_EXPORT2
00308 utext_nativeLength(UText *ut);
00309
00323 U_DRAFT UBool U_EXPORT2
00324 utext_isLengthExpensive(const UText *ut);
00325
00348 U_DRAFT UChar32 U_EXPORT2
00349 utext_char32At(UText *ut, int32_t nativeIndex);
00350
00351
00362 U_DRAFT UChar32 U_EXPORT2
00363 utext_current32(UText *ut);
00364
00365
00381 U_DRAFT UChar32 U_EXPORT2
00382 utext_next32(UText *ut);
00383
00384
00401 U_DRAFT UChar32 U_EXPORT2
00402 utext_previous32(UText *ut);
00403
00404
00419 U_DRAFT UChar32 U_EXPORT2
00420 utext_next32From(UText *ut, int32_t nativeIndex);
00421
00422
00423
00439 U_DRAFT UChar32 U_EXPORT2
00440 utext_previous32From(UText *ut, int32_t nativeIndex);
00441
00454 U_DRAFT int32_t U_EXPORT2
00455 utext_getNativeIndex(UText *ut);
00456
00480 U_DRAFT void U_EXPORT2
00481 utext_setNativeIndex(UText *ut, int32_t nativeIndex);
00482
00503 U_DRAFT UBool U_EXPORT2
00504 utext_moveIndex32(UText *ut, int32_t delta);
00505
00506
00536 U_DRAFT int32_t U_EXPORT2
00537 utext_extract(UText *ut,
00538 int32_t nativeStart, int32_t nativeLimit,
00539 UChar *dest, int32_t destCapacity,
00540 UErrorCode *status);
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00570 #define UTEXT_NEXT32(ut) \
00571 ((ut)->chunk.offset < (ut)->chunk.length && ((ut)->chunk.contents)[(ut)->chunk.offset]<0xd800 ? \
00572 ((ut)->chunk.contents)[((ut)->chunk.offset)++] : utext_next32(ut))
00573
00584 #define UTEXT_PREVIOUS32(ut) \
00585 ((ut)->chunk.offset > 0 && \
00586 (ut)->chunk.contents[(ut)->chunk.offset-1] < 0xd800 ? \
00587 (ut)->chunk.contents[--((ut)->chunk.offset)] : utext_previous32(ut))
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00611 U_DRAFT UBool U_EXPORT2
00612 utext_isWritable(const UText *ut);
00613
00614
00623 U_DRAFT UBool U_EXPORT2
00624 utext_hasMetaData(const UText *ut);
00625
00626
00654 U_DRAFT int32_t U_EXPORT2
00655 utext_replace(UText *ut,
00656 int32_t nativeStart, int32_t nativeLimit,
00657 const UChar *replacementText, int32_t replacementLength,
00658 UErrorCode *status);
00659
00660
00661
00689 U_DRAFT void U_EXPORT2
00690 utext_copy(UText *ut,
00691 int32_t nativeStart, int32_t nativeLimit,
00692 int32_t destIndex,
00693 UBool move,
00694 UErrorCode *status);
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00723 struct UTextChunk {
00725 const UChar *contents;
00726
00728 int32_t offset;
00729
00731 int32_t length;
00732
00734 int32_t nativeStart;
00735
00737 int32_t nativeLimit;
00738
00740 UBool nonUTF16Indexes;
00741
00743 UBool padding1, padding2, padding3;
00744
00746 int32_t padInt1, padInt2;
00747
00749 int32_t sizeOfStruct;
00750 };
00751
00752
00759 enum {
00765 UTEXT_PROVIDER_NON_UTF16_INDEXES = 0,
00770 UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
00777 UTEXT_PROVIDER_STABLE_CHUNKS = 2,
00784 UTEXT_PROVIDER_WRITABLE = 3,
00790 UTEXT_PROVIDER_HAS_META_DATA = 4
00791 };
00792
00830 typedef UText * U_CALLCONV
00831 UTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
00832
00833
00842 typedef int32_t U_CALLCONV
00843 UTextNativeLength(UText *ut);
00844
00870 typedef UBool U_CALLCONV
00871 UTextAccess(UText *ut, int32_t nativeIndex, UBool forward, UTextChunk *chunk);
00872
00900 typedef int32_t U_CALLCONV
00901 UTextExtract(UText *ut,
00902 int32_t nativeStart, int32_t nativeLimit,
00903 UChar *dest, int32_t destCapacity,
00904 UErrorCode *status);
00905
00935 typedef int32_t U_CALLCONV
00936 UTextReplace(UText *ut,
00937 int32_t nativeStart, int32_t nativeLimit,
00938 const UChar *replacementText, int32_t replacmentLength,
00939 UErrorCode *status);
00940
00969 typedef void U_CALLCONV
00970 UTextCopy(UText *ut,
00971 int32_t nativeStart, int32_t nativeLimit,
00972 int32_t nativeDest,
00973 UBool move,
00974 UErrorCode *status);
00975
00993 typedef int32_t U_CALLCONV
00994 UTextMapOffsetToNative(UText *ut, int32_t offset);
00995
01010 typedef int32_t U_CALLCONV
01011 UTextMapNativeIndexToUTF16(UText *ut, int32_t nativeIndex);
01012
01013
01031 typedef void U_CALLCONV
01032 UTextClose(UText *ut);
01033
01034
01046 struct UText {
01052 const void *context;
01053
01059 const void *p, *q, *r;
01060
01066 void *pExtra;
01067
01072 int32_t extraSize;
01073
01079 int32_t flags;
01080
01092 uint32_t magic;
01093
01094
01101 int32_t sizeOfStruct;
01102
01108 int32_t a, b, c;
01109
01110
01116 int32_t providerProperties;
01117
01118
01119
01124 UTextChunk chunk;
01125
01126
01133 UTextClone *clone;
01134
01142 UTextNativeLength *nativeLength;
01143
01150 UTextAccess *access;
01151
01158 UTextExtract *extract;
01159
01166 UTextReplace *replace;
01167
01174 UTextCopy *copy;
01175
01182 UTextMapOffsetToNative *mapOffsetToNative;
01183
01190 UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
01191
01198 UTextClose *close;
01199 };
01200
01201
01218 U_DRAFT UText * U_EXPORT2
01219 utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
01220
01224 enum {
01225 UTEXT_MAGIC = 0x345ad82c
01226 };
01227
01228
01233 #define UTEXT_CHUNK_INIT { \
01234 NULL, \
01235 0, \
01236 0, \
01237 0, \
01238 0, \
01239 FALSE, \
01240 FALSE, FALSE, FALSE, \
01241 0, 0, \
01242 sizeof(UTextChunk) \
01243 }
01244
01245
01246
01253 #define UTEXT_INITIALIZER_HEAD \
01254 NULL, \
01255 NULL, NULL, NULL, \
01256 NULL, \
01257 0, \
01258 0, \
01259 UTEXT_MAGIC, \
01260 sizeof(UText), \
01261 0, 0, 0, \
01262 0, \
01263 UTEXT_CHUNK_INIT
01264
01265
01266
01274 #define UTEXT_INITIALIZER { \
01275 UTEXT_INITIALIZER_HEAD, \
01276 NULL, \
01277 NULL, \
01278 NULL, \
01279 NULL, \
01280 NULL, \
01281 NULL, \
01282 NULL, NULL, \
01283 NULL \
01284 }
01285
01286
01287 U_CDECL_END
01288
01289
01290
01291 #endif
01292
01293 #endif