00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __UTEXT_H__
00020 #define __UTEXT_H__
00021
00140 #include "unicode/utypes.h"
00141 #include "unicode/uchar.h"
00142 #if U_SHOW_CPLUSPLUS_API
00143 #include "unicode/localpointer.h"
00144 #include "unicode/rep.h"
00145 #include "unicode/unistr.h"
00146 #include "unicode/chariter.h"
00147 #endif
00148
00149
00150 U_CDECL_BEGIN
00151
00152 struct UText;
00153 typedef struct UText UText;
00156
00157
00158
00159
00160
00161
00162
00183 U_STABLE UText * U_EXPORT2
00184 utext_close(UText *ut);
00185
00186 #if U_SHOW_CPLUSPLUS_API
00187
00188 U_NAMESPACE_BEGIN
00189
00199 U_DEFINE_LOCAL_OPEN_POINTER(LocalUTextPointer, UText, utext_close);
00200
00201 U_NAMESPACE_END
00202
00203 #endif
00204
00226 U_STABLE UText * U_EXPORT2
00227 utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
00228
00229
00244 U_STABLE UText * U_EXPORT2
00245 utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
00246
00247
00248 #if U_SHOW_CPLUSPLUS_API
00249
00261 U_STABLE UText * U_EXPORT2
00262 utext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
00263
00264
00277 U_STABLE UText * U_EXPORT2
00278 utext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode *status);
00279
00280
00293 U_STABLE UText * U_EXPORT2
00294 utext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
00295
00308 U_STABLE UText * U_EXPORT2
00309 utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *status);
00310
00311 #endif
00312
00313
00371 U_STABLE UText * U_EXPORT2
00372 utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
00373
00374
00386 U_STABLE UBool U_EXPORT2
00387 utext_equals(const UText *a, const UText *b);
00388
00389
00390
00391
00392
00393
00394
00395
00407 U_STABLE int64_t U_EXPORT2
00408 utext_nativeLength(UText *ut);
00409
00423 U_STABLE UBool U_EXPORT2
00424 utext_isLengthExpensive(const UText *ut);
00425
00451 U_STABLE UChar32 U_EXPORT2
00452 utext_char32At(UText *ut, int64_t nativeIndex);
00453
00454
00465 U_STABLE UChar32 U_EXPORT2
00466 utext_current32(UText *ut);
00467
00468
00487 U_STABLE UChar32 U_EXPORT2
00488 utext_next32(UText *ut);
00489
00490
00508 U_STABLE UChar32 U_EXPORT2
00509 utext_previous32(UText *ut);
00510
00511
00530 U_STABLE UChar32 U_EXPORT2
00531 utext_next32From(UText *ut, int64_t nativeIndex);
00532
00533
00534
00550 U_STABLE UChar32 U_EXPORT2
00551 utext_previous32From(UText *ut, int64_t nativeIndex);
00552
00565 U_STABLE int64_t U_EXPORT2
00566 utext_getNativeIndex(const UText *ut);
00567
00591 U_STABLE void U_EXPORT2
00592 utext_setNativeIndex(UText *ut, int64_t nativeIndex);
00593
00610 U_STABLE UBool U_EXPORT2
00611 utext_moveIndex32(UText *ut, int32_t delta);
00612
00635 U_STABLE int64_t U_EXPORT2
00636 utext_getPreviousNativeIndex(UText *ut);
00637
00638
00673 U_STABLE int32_t U_EXPORT2
00674 utext_extract(UText *ut,
00675 int64_t nativeStart, int64_t nativeLimit,
00676 UChar *dest, int32_t destCapacity,
00677 UErrorCode *status);
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696 #ifndef U_HIDE_INTERNAL_API
00697
00706 #define UTEXT_CURRENT32(ut) \
00707 ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
00708 ((ut)->chunkContents)[((ut)->chunkOffset)] : utext_current32(ut))
00709 #endif
00710
00722 #define UTEXT_NEXT32(ut) \
00723 ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
00724 ((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut))
00725
00736 #define UTEXT_PREVIOUS32(ut) \
00737 ((ut)->chunkOffset > 0 && \
00738 (ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \
00739 (ut)->chunkContents[--((ut)->chunkOffset)] : utext_previous32(ut))
00740
00753 #define UTEXT_GETNATIVEINDEX(ut) \
00754 ((ut)->chunkOffset <= (ut)->nativeIndexingLimit? \
00755 (ut)->chunkNativeStart+(ut)->chunkOffset : \
00756 (ut)->pFuncs->mapOffsetToNative(ut))
00757
00769 #define UTEXT_SETNATIVEINDEX(ut, ix) UPRV_BLOCK_MACRO_BEGIN { \
00770 int64_t __offset = (ix) - (ut)->chunkNativeStart; \
00771 if (__offset>=0 && __offset<(int64_t)(ut)->nativeIndexingLimit && (ut)->chunkContents[__offset]<0xdc00) { \
00772 (ut)->chunkOffset=(int32_t)__offset; \
00773 } else { \
00774 utext_setNativeIndex((ut), (ix)); \
00775 } \
00776 } UPRV_BLOCK_MACRO_END
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00807 U_STABLE UBool U_EXPORT2
00808 utext_isWritable(const UText *ut);
00809
00810
00819 U_STABLE UBool U_EXPORT2
00820 utext_hasMetaData(const UText *ut);
00821
00822
00850 U_STABLE int32_t U_EXPORT2
00851 utext_replace(UText *ut,
00852 int64_t nativeStart, int64_t nativeLimit,
00853 const UChar *replacementText, int32_t replacementLength,
00854 UErrorCode *status);
00855
00856
00857
00890 U_STABLE void U_EXPORT2
00891 utext_copy(UText *ut,
00892 int64_t nativeStart, int64_t nativeLimit,
00893 int64_t destIndex,
00894 UBool move,
00895 UErrorCode *status);
00896
00897
00919 U_STABLE void U_EXPORT2
00920 utext_freeze(UText *ut);
00921
00922
00929 enum {
00934 UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
00941 UTEXT_PROVIDER_STABLE_CHUNKS = 2,
00948 UTEXT_PROVIDER_WRITABLE = 3,
00954 UTEXT_PROVIDER_HAS_META_DATA = 4,
00962 UTEXT_PROVIDER_OWNS_TEXT = 5
00963 };
00964
01002 typedef UText * U_CALLCONV
01003 UTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
01004
01005
01014 typedef int64_t U_CALLCONV
01015 UTextNativeLength(UText *ut);
01016
01042 typedef UBool U_CALLCONV
01043 UTextAccess(UText *ut, int64_t nativeIndex, UBool forward);
01044
01072 typedef int32_t U_CALLCONV
01073 UTextExtract(UText *ut,
01074 int64_t nativeStart, int64_t nativeLimit,
01075 UChar *dest, int32_t destCapacity,
01076 UErrorCode *status);
01077
01107 typedef int32_t U_CALLCONV
01108 UTextReplace(UText *ut,
01109 int64_t nativeStart, int64_t nativeLimit,
01110 const UChar *replacementText, int32_t replacmentLength,
01111 UErrorCode *status);
01112
01141 typedef void U_CALLCONV
01142 UTextCopy(UText *ut,
01143 int64_t nativeStart, int64_t nativeLimit,
01144 int64_t nativeDest,
01145 UBool move,
01146 UErrorCode *status);
01147
01161 typedef int64_t U_CALLCONV
01162 UTextMapOffsetToNative(const UText *ut);
01163
01179 typedef int32_t U_CALLCONV
01180 UTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex);
01181
01182
01200 typedef void U_CALLCONV
01201 UTextClose(UText *ut);
01202
01203
01213 struct UTextFuncs {
01228 int32_t tableSize;
01229
01235 int32_t reserved1, reserved2, reserved3;
01236
01237
01244 UTextClone *clone;
01245
01253 UTextNativeLength *nativeLength;
01254
01261 UTextAccess *access;
01262
01269 UTextExtract *extract;
01270
01277 UTextReplace *replace;
01278
01285 UTextCopy *copy;
01286
01293 UTextMapOffsetToNative *mapOffsetToNative;
01294
01301 UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
01302
01309 UTextClose *close;
01310
01315 UTextClose *spare1;
01316
01321 UTextClose *spare2;
01322
01327 UTextClose *spare3;
01328
01329 };
01334 typedef struct UTextFuncs UTextFuncs;
01335
01347 struct UText {
01360 uint32_t magic;
01361
01362
01368 int32_t flags;
01369
01370
01376 int32_t providerProperties;
01377
01384 int32_t sizeOfStruct;
01385
01386
01387
01388
01394 int64_t chunkNativeLimit;
01395
01400 int32_t extraSize;
01401
01409 int32_t nativeIndexingLimit;
01410
01411
01412
01417 int64_t chunkNativeStart;
01418
01424 int32_t chunkOffset;
01425
01430 int32_t chunkLength;
01431
01432
01433
01434
01441 const UChar *chunkContents;
01442
01447 const UTextFuncs *pFuncs;
01448
01454 void *pExtra;
01455
01462 const void *context;
01463
01464
01465
01471 const void *p;
01477 const void *q;
01483 const void *r;
01484
01490 void *privP;
01491
01492
01493
01494
01495
01501 int64_t a;
01502
01508 int32_t b;
01509
01515 int32_t c;
01516
01517
01518
01519
01525 int64_t privA;
01531 int32_t privB;
01537 int32_t privC;
01538 };
01539
01540
01557 U_STABLE UText * U_EXPORT2
01558 utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
01559
01560
01566 enum {
01567 UTEXT_MAGIC = 0x345ad82c
01568 };
01569
01577 #define UTEXT_INITIALIZER { \
01578 UTEXT_MAGIC, \
01579 0, \
01580 0, \
01581 sizeof(UText), \
01582 0, \
01583 0, \
01584 0, \
01585 0, \
01586 0, \
01587 0, \
01588 NULL, \
01589 NULL, \
01590 NULL, \
01591 NULL, \
01592 NULL, NULL, NULL, \
01593 NULL, \
01594 0, 0, 0, \
01595 0, 0, 0 \
01596 }
01597
01598
01599 U_CDECL_END
01600
01601
01602
01603 #endif