]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | /* |
4 | ******************************************************************************* | |
5 | * | |
51004dcb | 6 | * Copyright (C) 1998-2012, International Business Machines |
b75a7d8f A |
7 | * Corporation and others. All Rights Reserved. |
8 | * | |
9 | ******************************************************************************* | |
10 | * | |
11 | * File ustr.h | |
12 | * | |
13 | * Modification History: | |
14 | * | |
15 | * Date Name Description | |
16 | * 05/28/99 stephen Creation. | |
17 | ******************************************************************************* | |
18 | */ | |
19 | ||
20 | #ifndef USTR_H | |
21 | #define USTR_H 1 | |
22 | ||
23 | #include "unicode/utypes.h" | |
24 | ||
340931cb | 25 | #define U_APPEND_CHAR32(c,target,len) UPRV_BLOCK_MACRO_BEGIN { \ |
b75a7d8f A |
26 | if (c <= 0xffff) \ |
27 | { \ | |
28 | *(target)++ = (UChar) c; \ | |
29 | len=1; \ | |
30 | } \ | |
31 | else \ | |
32 | { \ | |
374ca955 A |
33 | target[0] = U16_LEAD(c); \ |
34 | target[1] = U16_TRAIL(c); \ | |
b75a7d8f | 35 | len=2; \ |
374ca955 | 36 | target +=2; \ |
b75a7d8f | 37 | } \ |
340931cb | 38 | } UPRV_BLOCK_MACRO_END |
b75a7d8f | 39 | |
340931cb | 40 | #define U_APPEND_CHAR32_ONLY(c,target) UPRV_BLOCK_MACRO_BEGIN { \ |
51004dcb A |
41 | if (c <= 0xffff) \ |
42 | { \ | |
43 | *(target)++ = (UChar) c; \ | |
44 | } \ | |
45 | else \ | |
46 | { \ | |
47 | target[0] = U16_LEAD(c); \ | |
48 | target[1] = U16_TRAIL(c); \ | |
49 | target +=2; \ | |
50 | } \ | |
340931cb | 51 | } UPRV_BLOCK_MACRO_END |
51004dcb | 52 | |
b75a7d8f A |
53 | /* A C representation of a string "object" (to avoid realloc all the time) */ |
54 | struct UString { | |
55 | UChar *fChars; | |
56 | int32_t fLength; | |
57 | int32_t fCapacity; | |
58 | }; | |
59 | ||
4388f060 | 60 | U_CFUNC void ustr_init(struct UString *s); |
b75a7d8f | 61 | |
4388f060 | 62 | U_CFUNC void |
b75a7d8f A |
63 | ustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status); |
64 | ||
4388f060 | 65 | U_CFUNC void ustr_deinit(struct UString *s); |
b75a7d8f | 66 | |
4388f060 | 67 | U_CFUNC void ustr_setlen(struct UString *s, int32_t len, UErrorCode *status); |
b75a7d8f | 68 | |
4388f060 A |
69 | U_CFUNC void ustr_cpy(struct UString *dst, const struct UString *src, |
70 | UErrorCode *status); | |
b75a7d8f | 71 | |
4388f060 A |
72 | U_CFUNC void ustr_cat(struct UString *dst, const struct UString *src, |
73 | UErrorCode *status); | |
b75a7d8f | 74 | |
4388f060 A |
75 | U_CFUNC void ustr_ncat(struct UString *dst, const struct UString *src, |
76 | int32_t n, UErrorCode *status); | |
b75a7d8f | 77 | |
4388f060 A |
78 | U_CFUNC void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status); |
79 | U_CFUNC void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status); | |
80 | U_CFUNC void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status); | |
b75a7d8f | 81 | #endif |