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
00138 #include "unicode/utypes.h"
00139 #ifdef XP_CPLUSPLUS
00140 #include "unicode/rep.h"
00141 #include "unicode/unistr.h"
00142 #include "unicode/chariter.h"
00143 #endif
00144
00145
00146 U_CDECL_BEGIN
00147
00148 struct UText;
00149 typedef struct UText UText;
00152
00153
00154
00155
00156
00157
00158
00179 U_STABLE UText * U_EXPORT2
00180 utext_close(UText *ut);
00181
00182
00204 U_STABLE UText * U_EXPORT2
00205 utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
00206
00207
00222 U_STABLE UText * U_EXPORT2
00223 utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
00224
00225
00226 #ifdef XP_CPLUSPLUS
00227
00239 U_STABLE UText * U_EXPORT2
00240 utext_openUnicodeString(UText *ut, U_NAMESPACE_QUALIFIER UnicodeString *s, UErrorCode *status);
00241
00242
00255 U_STABLE UText * U_EXPORT2
00256 utext_openConstUnicodeString(UText *ut, const U_NAMESPACE_QUALIFIER UnicodeString *s, UErrorCode *status);
00257
00258
00271 U_STABLE UText * U_EXPORT2
00272 utext_openReplaceable(UText *ut, U_NAMESPACE_QUALIFIER Replaceable *rep, UErrorCode *status);
00273
00286 U_STABLE UText * U_EXPORT2
00287 utext_openCharacterIterator(UText *ut, U_NAMESPACE_QUALIFIER CharacterIterator *ic, UErrorCode *status);
00288
00289 #endif
00290
00291
00349 U_STABLE UText * U_EXPORT2
00350 utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
00351
00352
00364 U_STABLE UBool U_EXPORT2
00365 utext_equals(const UText *a, const UText *b);
00366
00367
00368
00369
00370
00371
00372
00373
00385 U_STABLE int64_t U_EXPORT2
00386 utext_nativeLength(UText *ut);
00387
00401 U_STABLE UBool U_EXPORT2
00402 utext_isLengthExpensive(const UText *ut);
00403
00429 U_STABLE UChar32 U_EXPORT2
00430 utext_char32At(UText *ut, int64_t nativeIndex);
00431
00432
00443 U_STABLE UChar32 U_EXPORT2
00444 utext_current32(UText *ut);
00445
00446
00465 U_STABLE UChar32 U_EXPORT2
00466 utext_next32(UText *ut);
00467
00468
00486 U_STABLE UChar32 U_EXPORT2
00487 utext_previous32(UText *ut);
00488
00489
00508 U_STABLE UChar32 U_EXPORT2
00509 utext_next32From(UText *ut, int64_t nativeIndex);
00510
00511
00512
00528 U_STABLE UChar32 U_EXPORT2
00529 utext_previous32From(UText *ut, int64_t nativeIndex);
00530
00543 U_STABLE int64_t U_EXPORT2
00544 utext_getNativeIndex(const UText *ut);
00545
00569 U_STABLE void U_EXPORT2
00570 utext_setNativeIndex(UText *ut, int64_t nativeIndex);
00571
00588 U_STABLE UBool U_EXPORT2
00589 utext_moveIndex32(UText *ut, int32_t delta);
00590
00613 U_STABLE int64_t U_EXPORT2
00614 utext_getPreviousNativeIndex(UText *ut);
00615
00616
00651 U_STABLE int32_t U_EXPORT2
00652 utext_extract(UText *ut,
00653 int64_t nativeStart, int64_t nativeLimit,
00654 UChar *dest, int32_t destCapacity,
00655 UErrorCode *status);
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00684 #define UTEXT_NEXT32(ut) \
00685 ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
00686 ((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut))
00687
00698 #define UTEXT_PREVIOUS32(ut) \
00699 ((ut)->chunkOffset > 0 && \
00700 (ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \
00701 (ut)->chunkContents[--((ut)->chunkOffset)] : utext_previous32(ut))
00702
00715 #define UTEXT_GETNATIVEINDEX(ut) \
00716 ((ut)->chunkOffset <= (ut)->nativeIndexingLimit? \
00717 (ut)->chunkNativeStart+(ut)->chunkOffset : \
00718 (ut)->pFuncs->mapOffsetToNative(ut))
00719
00731 #define UTEXT_SETNATIVEINDEX(ut, ix) \
00732 { int64_t __offset = (ix) - (ut)->chunkNativeStart; \
00733 if (__offset>=0 && __offset<=(int64_t)(ut)->nativeIndexingLimit) { \
00734 (ut)->chunkOffset=(int32_t)__offset; \
00735 } else { \
00736 utext_setNativeIndex((ut), (ix)); } }
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00767 U_STABLE UBool U_EXPORT2
00768 utext_isWritable(const UText *ut);
00769
00770
00779 U_STABLE UBool U_EXPORT2
00780 utext_hasMetaData(const UText *ut);
00781
00782
00810 U_STABLE int32_t U_EXPORT2
00811 utext_replace(UText *ut,
00812 int64_t nativeStart, int64_t nativeLimit,
00813 const UChar *replacementText, int32_t replacementLength,
00814 UErrorCode *status);
00815
00816
00817
00850 U_STABLE void U_EXPORT2
00851 utext_copy(UText *ut,
00852 int64_t nativeStart, int64_t nativeLimit,
00853 int64_t destIndex,
00854 UBool move,
00855 UErrorCode *status);
00856
00857
00879 U_STABLE void U_EXPORT2
00880 utext_freeze(UText *ut);
00881
00882
00889 enum {
00894 UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
00901 UTEXT_PROVIDER_STABLE_CHUNKS = 2,
00908 UTEXT_PROVIDER_WRITABLE = 3,
00914 UTEXT_PROVIDER_HAS_META_DATA = 4,
00922 UTEXT_PROVIDER_OWNS_TEXT = 5
00923 };
00924
00962 typedef UText * U_CALLCONV
00963 UTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
00964
00965
00974 typedef int64_t U_CALLCONV
00975 UTextNativeLength(UText *ut);
00976
01002 typedef UBool U_CALLCONV
01003 UTextAccess(UText *ut, int64_t nativeIndex, UBool forward);
01004
01032 typedef int32_t U_CALLCONV
01033 UTextExtract(UText *ut,
01034 int64_t nativeStart, int64_t nativeLimit,
01035 UChar *dest, int32_t destCapacity,
01036 UErrorCode *status);
01037
01067 typedef int32_t U_CALLCONV
01068 UTextReplace(UText *ut,
01069 int64_t nativeStart, int64_t nativeLimit,
01070 const UChar *replacementText, int32_t replacmentLength,
01071 UErrorCode *status);
01072
01101 typedef void U_CALLCONV
01102 UTextCopy(UText *ut,
01103 int64_t nativeStart, int64_t nativeLimit,
01104 int64_t nativeDest,
01105 UBool move,
01106 UErrorCode *status);
01107
01121 typedef int64_t U_CALLCONV
01122 UTextMapOffsetToNative(const UText *ut);
01123
01139 typedef int32_t U_CALLCONV
01140 UTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex);
01141
01142
01160 typedef void U_CALLCONV
01161 UTextClose(UText *ut);
01162
01163
01173 struct UTextFuncs {
01188 int32_t tableSize;
01189
01195 int32_t reserved1, reserved2, reserved3;
01196
01197
01204 UTextClone *clone;
01205
01213 UTextNativeLength *nativeLength;
01214
01221 UTextAccess *access;
01222
01229 UTextExtract *extract;
01230
01237 UTextReplace *replace;
01238
01245 UTextCopy *copy;
01246
01253 UTextMapOffsetToNative *mapOffsetToNative;
01254
01261 UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
01262
01269 UTextClose *close;
01270
01276 UTextClose *spare1;
01281 UTextClose *spare2;
01282
01287 UTextClose *spare3;
01288
01289 };
01294 typedef struct UTextFuncs UTextFuncs;
01295
01307 struct UText {
01320 uint32_t magic;
01321
01322
01328 int32_t flags;
01329
01330
01336 int32_t providerProperties;
01337
01344 int32_t sizeOfStruct;
01345
01346
01347
01348
01354 int64_t chunkNativeLimit;
01355
01360 int32_t extraSize;
01361
01369 int32_t nativeIndexingLimit;
01370
01371
01372
01377 int64_t chunkNativeStart;
01378
01384 int32_t chunkOffset;
01385
01390 int32_t chunkLength;
01391
01392
01393
01394
01401 const UChar *chunkContents;
01402
01407 const UTextFuncs *pFuncs;
01408
01414 void *pExtra;
01415
01422 const void *context;
01423
01424
01425
01431 const void *p;
01437 const void *q;
01443 const void *r;
01444
01450 void *privP;
01451
01452
01453
01454
01455
01461 int64_t a;
01462
01468 int32_t b;
01469
01475 int32_t c;
01476
01477
01478
01479
01485 int64_t privA;
01491 int32_t privB;
01497 int32_t privC;
01498 };
01499
01500
01517 U_STABLE UText * U_EXPORT2
01518 utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
01519
01525 enum {
01526 UTEXT_MAGIC = 0x345ad82c
01527 };
01528
01536 #define UTEXT_INITIALIZER { \
01537 UTEXT_MAGIC, \
01538 0, \
01539 0, \
01540 sizeof(UText), \
01541 0, \
01542 0, \
01543 0, \
01544 0, \
01545 0, \
01546 0, \
01547 NULL, \
01548 NULL, \
01549 NULL, \
01550 NULL, \
01551 NULL, NULL, NULL, \
01552 NULL, \
01553 0, 0, 0, \
01554 0, 0, 0 \
01555 }
01556
01557
01558 U_CDECL_END
01559
01560
01561
01562 #endif