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