michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 1998-2012, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * michael@0: * File ustr.h michael@0: * michael@0: * Modification History: michael@0: * michael@0: * Date Name Description michael@0: * 05/28/99 stephen Creation. michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #ifndef USTR_H michael@0: #define USTR_H 1 michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #define U_APPEND_CHAR32(c,target,len) { \ michael@0: if (c <= 0xffff) \ michael@0: { \ michael@0: *(target)++ = (UChar) c; \ michael@0: len=1; \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: target[0] = U16_LEAD(c); \ michael@0: target[1] = U16_TRAIL(c); \ michael@0: len=2; \ michael@0: target +=2; \ michael@0: } \ michael@0: } michael@0: michael@0: #define U_APPEND_CHAR32_ONLY(c,target) { \ michael@0: if (c <= 0xffff) \ michael@0: { \ michael@0: *(target)++ = (UChar) c; \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: target[0] = U16_LEAD(c); \ michael@0: target[1] = U16_TRAIL(c); \ michael@0: target +=2; \ michael@0: } \ michael@0: } michael@0: michael@0: /* A C representation of a string "object" (to avoid realloc all the time) */ michael@0: struct UString { michael@0: UChar *fChars; michael@0: int32_t fLength; michael@0: int32_t fCapacity; michael@0: }; michael@0: michael@0: U_CFUNC void ustr_init(struct UString *s); michael@0: michael@0: U_CFUNC void michael@0: ustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status); michael@0: michael@0: U_CFUNC void ustr_deinit(struct UString *s); michael@0: michael@0: U_CFUNC void ustr_setlen(struct UString *s, int32_t len, UErrorCode *status); michael@0: michael@0: U_CFUNC void ustr_cpy(struct UString *dst, const struct UString *src, michael@0: UErrorCode *status); michael@0: michael@0: U_CFUNC void ustr_cat(struct UString *dst, const struct UString *src, michael@0: UErrorCode *status); michael@0: michael@0: U_CFUNC void ustr_ncat(struct UString *dst, const struct UString *src, michael@0: int32_t n, UErrorCode *status); michael@0: michael@0: U_CFUNC void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status); michael@0: U_CFUNC void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status); michael@0: U_CFUNC void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status); michael@0: #endif