• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *******************************************************************************
3 *
4 *   Copyright (C) 1998-2003, International Business Machines
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     {                                                           \
31         target[0] = U16_LEAD(c);                                \
32         target[1] = U16_TRAIL(c);                               \
33         len=2;                                                  \
34         target +=2;                                             \
35     }                                                           \
36 }
37 
38 /* A C representation of a string "object" (to avoid realloc all the time) */
39 struct UString {
40   UChar *fChars;
41   int32_t fLength;
42   int32_t fCapacity;
43 };
44 
45 void ustr_init(struct UString *s);
46 
47 void
48 ustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status);
49 
50 void ustr_deinit(struct UString *s);
51 
52 void ustr_setlen(struct UString *s, int32_t len, UErrorCode *status);
53 
54 void ustr_cpy(struct UString *dst, const struct UString *src,
55           UErrorCode *status);
56 
57 void ustr_cat(struct UString *dst, const struct UString *src,
58           UErrorCode *status);
59 
60 void ustr_ncat(struct UString *dst, const struct UString *src,
61            int32_t n, UErrorCode *status);
62 
63 void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status);
64 void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status);
65 void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status);
66 #endif
67