Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (C) 1999-2011, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * file name: ustr_imp.h |
michael@0 | 7 | * encoding: US-ASCII |
michael@0 | 8 | * tab size: 8 (not used) |
michael@0 | 9 | * indentation:4 |
michael@0 | 10 | * |
michael@0 | 11 | * created on: 2001jan30 |
michael@0 | 12 | * created by: Markus W. Scherer |
michael@0 | 13 | */ |
michael@0 | 14 | |
michael@0 | 15 | #ifndef __USTR_IMP_H__ |
michael@0 | 16 | #define __USTR_IMP_H__ |
michael@0 | 17 | |
michael@0 | 18 | #include "unicode/utypes.h" |
michael@0 | 19 | #include "unicode/uiter.h" |
michael@0 | 20 | #include "ucase.h" |
michael@0 | 21 | |
michael@0 | 22 | /** Simple declaration to avoid including unicode/ubrk.h. */ |
michael@0 | 23 | #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR |
michael@0 | 24 | # define UBRK_TYPEDEF_UBREAK_ITERATOR |
michael@0 | 25 | typedef struct UBreakIterator UBreakIterator; |
michael@0 | 26 | #endif |
michael@0 | 27 | |
michael@0 | 28 | #ifndef U_COMPARE_IGNORE_CASE |
michael@0 | 29 | /* see also unorm.h */ |
michael@0 | 30 | /** |
michael@0 | 31 | * Option bit for unorm_compare: |
michael@0 | 32 | * Perform case-insensitive comparison. |
michael@0 | 33 | */ |
michael@0 | 34 | #define U_COMPARE_IGNORE_CASE 0x10000 |
michael@0 | 35 | #endif |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Internal option for unorm_cmpEquivFold() for strncmp style. |
michael@0 | 39 | * If set, checks for both string length and terminating NUL. |
michael@0 | 40 | */ |
michael@0 | 41 | #define _STRNCMP_STYLE 0x1000 |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * Compare two strings in code point order or code unit order. |
michael@0 | 45 | * Works in strcmp style (both lengths -1), |
michael@0 | 46 | * strncmp style (lengths equal and >=0, flag TRUE), |
michael@0 | 47 | * and memcmp/UnicodeString style (at least one length >=0). |
michael@0 | 48 | */ |
michael@0 | 49 | U_CFUNC int32_t U_EXPORT2 |
michael@0 | 50 | uprv_strCompare(const UChar *s1, int32_t length1, |
michael@0 | 51 | const UChar *s2, int32_t length2, |
michael@0 | 52 | UBool strncmpStyle, UBool codePointOrder); |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Internal API, used by u_strcasecmp() etc. |
michael@0 | 56 | * Compare strings case-insensitively, |
michael@0 | 57 | * in code point order or code unit order. |
michael@0 | 58 | */ |
michael@0 | 59 | U_CFUNC int32_t |
michael@0 | 60 | u_strcmpFold(const UChar *s1, int32_t length1, |
michael@0 | 61 | const UChar *s2, int32_t length2, |
michael@0 | 62 | uint32_t options, |
michael@0 | 63 | UErrorCode *pErrorCode); |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Are the Unicode properties loaded? |
michael@0 | 67 | * This must be used before internal functions are called that do |
michael@0 | 68 | * not perform this check. |
michael@0 | 69 | * Generate a debug assertion failure if data is not loaded. |
michael@0 | 70 | */ |
michael@0 | 71 | U_CFUNC UBool |
michael@0 | 72 | uprv_haveProperties(UErrorCode *pErrorCode); |
michael@0 | 73 | |
michael@0 | 74 | /** |
michael@0 | 75 | * Load the Unicode property data. |
michael@0 | 76 | * Intended primarily for use from u_init(). |
michael@0 | 77 | * Has no effect if property data is already loaded. |
michael@0 | 78 | * NOT thread safe. |
michael@0 | 79 | */ |
michael@0 | 80 | /*U_CFUNC int8_t |
michael@0 | 81 | uprv_loadPropsData(UErrorCode *errorCode);*/ |
michael@0 | 82 | |
michael@0 | 83 | /* |
michael@0 | 84 | * Internal string casing functions implementing |
michael@0 | 85 | * ustring.h/ustrcase.c and UnicodeString case mapping functions. |
michael@0 | 86 | */ |
michael@0 | 87 | |
michael@0 | 88 | struct UCaseMap { |
michael@0 | 89 | const UCaseProps *csp; |
michael@0 | 90 | #if !UCONFIG_NO_BREAK_ITERATION |
michael@0 | 91 | UBreakIterator *iter; /* We adopt the iterator, so we own it. */ |
michael@0 | 92 | #endif |
michael@0 | 93 | char locale[32]; |
michael@0 | 94 | int32_t locCache; |
michael@0 | 95 | uint32_t options; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | #ifndef __UCASEMAP_H__ |
michael@0 | 99 | typedef struct UCaseMap UCaseMap; |
michael@0 | 100 | #endif |
michael@0 | 101 | |
michael@0 | 102 | #if UCONFIG_NO_BREAK_ITERATION |
michael@0 | 103 | # define UCASEMAP_INITIALIZER { NULL, { 0 }, 0, 0 } |
michael@0 | 104 | #else |
michael@0 | 105 | # define UCASEMAP_INITIALIZER { NULL, NULL, { 0 }, 0, 0 } |
michael@0 | 106 | #endif |
michael@0 | 107 | |
michael@0 | 108 | U_CFUNC void |
michael@0 | 109 | ustrcase_setTempCaseMapLocale(UCaseMap *csm, const char *locale); |
michael@0 | 110 | |
michael@0 | 111 | #ifndef U_STRING_CASE_MAPPER_DEFINED |
michael@0 | 112 | #define U_STRING_CASE_MAPPER_DEFINED |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * String case mapping function type, used by ustrcase_map(). |
michael@0 | 116 | * All error checking must be done. |
michael@0 | 117 | * The UCaseMap must be fully initialized, with locale and/or iter set as needed. |
michael@0 | 118 | * src and dest must not overlap. |
michael@0 | 119 | */ |
michael@0 | 120 | typedef int32_t U_CALLCONV |
michael@0 | 121 | UStringCaseMapper(const UCaseMap *csm, |
michael@0 | 122 | UChar *dest, int32_t destCapacity, |
michael@0 | 123 | const UChar *src, int32_t srcLength, |
michael@0 | 124 | UErrorCode *pErrorCode); |
michael@0 | 125 | |
michael@0 | 126 | #endif |
michael@0 | 127 | |
michael@0 | 128 | /** Implements UStringCaseMapper. */ |
michael@0 | 129 | U_CFUNC int32_t U_CALLCONV |
michael@0 | 130 | ustrcase_internalToLower(const UCaseMap *csm, |
michael@0 | 131 | UChar *dest, int32_t destCapacity, |
michael@0 | 132 | const UChar *src, int32_t srcLength, |
michael@0 | 133 | UErrorCode *pErrorCode); |
michael@0 | 134 | |
michael@0 | 135 | /** Implements UStringCaseMapper. */ |
michael@0 | 136 | U_CFUNC int32_t U_CALLCONV |
michael@0 | 137 | ustrcase_internalToUpper(const UCaseMap *csm, |
michael@0 | 138 | UChar *dest, int32_t destCapacity, |
michael@0 | 139 | const UChar *src, int32_t srcLength, |
michael@0 | 140 | UErrorCode *pErrorCode); |
michael@0 | 141 | |
michael@0 | 142 | #if !UCONFIG_NO_BREAK_ITERATION |
michael@0 | 143 | |
michael@0 | 144 | /** Implements UStringCaseMapper. */ |
michael@0 | 145 | U_CFUNC int32_t U_CALLCONV |
michael@0 | 146 | ustrcase_internalToTitle(const UCaseMap *csm, |
michael@0 | 147 | UChar *dest, int32_t destCapacity, |
michael@0 | 148 | const UChar *src, int32_t srcLength, |
michael@0 | 149 | UErrorCode *pErrorCode); |
michael@0 | 150 | |
michael@0 | 151 | #endif |
michael@0 | 152 | |
michael@0 | 153 | /** Implements UStringCaseMapper. */ |
michael@0 | 154 | U_CFUNC int32_t U_CALLCONV |
michael@0 | 155 | ustrcase_internalFold(const UCaseMap *csm, |
michael@0 | 156 | UChar *dest, int32_t destCapacity, |
michael@0 | 157 | const UChar *src, int32_t srcLength, |
michael@0 | 158 | UErrorCode *pErrorCode); |
michael@0 | 159 | |
michael@0 | 160 | /** |
michael@0 | 161 | * Implements argument checking and buffer handling |
michael@0 | 162 | * for string case mapping as a common function. |
michael@0 | 163 | */ |
michael@0 | 164 | U_CFUNC int32_t |
michael@0 | 165 | ustrcase_map(const UCaseMap *csm, |
michael@0 | 166 | UChar *dest, int32_t destCapacity, |
michael@0 | 167 | const UChar *src, int32_t srcLength, |
michael@0 | 168 | UStringCaseMapper *stringCaseMapper, |
michael@0 | 169 | UErrorCode *pErrorCode); |
michael@0 | 170 | |
michael@0 | 171 | /** |
michael@0 | 172 | * UTF-8 string case mapping function type, used by ucasemap_mapUTF8(). |
michael@0 | 173 | * UTF-8 version of UStringCaseMapper. |
michael@0 | 174 | * All error checking must be done. |
michael@0 | 175 | * The UCaseMap must be fully initialized, with locale and/or iter set as needed. |
michael@0 | 176 | * src and dest must not overlap. |
michael@0 | 177 | */ |
michael@0 | 178 | typedef int32_t U_CALLCONV |
michael@0 | 179 | UTF8CaseMapper(const UCaseMap *csm, |
michael@0 | 180 | uint8_t *dest, int32_t destCapacity, |
michael@0 | 181 | const uint8_t *src, int32_t srcLength, |
michael@0 | 182 | UErrorCode *pErrorCode); |
michael@0 | 183 | |
michael@0 | 184 | /** Implements UTF8CaseMapper. */ |
michael@0 | 185 | U_CFUNC int32_t U_CALLCONV |
michael@0 | 186 | ucasemap_internalUTF8ToTitle(const UCaseMap *csm, |
michael@0 | 187 | uint8_t *dest, int32_t destCapacity, |
michael@0 | 188 | const uint8_t *src, int32_t srcLength, |
michael@0 | 189 | UErrorCode *pErrorCode); |
michael@0 | 190 | |
michael@0 | 191 | /** |
michael@0 | 192 | * Implements argument checking and buffer handling |
michael@0 | 193 | * for UTF-8 string case mapping as a common function. |
michael@0 | 194 | */ |
michael@0 | 195 | U_CFUNC int32_t |
michael@0 | 196 | ucasemap_mapUTF8(const UCaseMap *csm, |
michael@0 | 197 | uint8_t *dest, int32_t destCapacity, |
michael@0 | 198 | const uint8_t *src, int32_t srcLength, |
michael@0 | 199 | UTF8CaseMapper *stringCaseMapper, |
michael@0 | 200 | UErrorCode *pErrorCode); |
michael@0 | 201 | |
michael@0 | 202 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 203 | ustr_hashUCharsN(const UChar *str, int32_t length); |
michael@0 | 204 | |
michael@0 | 205 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 206 | ustr_hashCharsN(const char *str, int32_t length); |
michael@0 | 207 | |
michael@0 | 208 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 209 | ustr_hashICharsN(const char *str, int32_t length); |
michael@0 | 210 | |
michael@0 | 211 | /** |
michael@0 | 212 | * NUL-terminate a UChar * string if possible. |
michael@0 | 213 | * If length < destCapacity then NUL-terminate. |
michael@0 | 214 | * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING. |
michael@0 | 215 | * If length > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR. |
michael@0 | 216 | * |
michael@0 | 217 | * @param dest Destination buffer, can be NULL if destCapacity==0. |
michael@0 | 218 | * @param destCapacity Number of UChars available at dest. |
michael@0 | 219 | * @param length Number of UChars that were (to be) written to dest. |
michael@0 | 220 | * @param pErrorCode ICU error code. |
michael@0 | 221 | * @return length |
michael@0 | 222 | */ |
michael@0 | 223 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 224 | u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); |
michael@0 | 225 | |
michael@0 | 226 | /** |
michael@0 | 227 | * NUL-terminate a char * string if possible. |
michael@0 | 228 | * Same as u_terminateUChars() but for a different string type. |
michael@0 | 229 | */ |
michael@0 | 230 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 231 | u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); |
michael@0 | 232 | |
michael@0 | 233 | /** |
michael@0 | 234 | * NUL-terminate a UChar32 * string if possible. |
michael@0 | 235 | * Same as u_terminateUChars() but for a different string type. |
michael@0 | 236 | */ |
michael@0 | 237 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 238 | u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); |
michael@0 | 239 | |
michael@0 | 240 | /** |
michael@0 | 241 | * NUL-terminate a wchar_t * string if possible. |
michael@0 | 242 | * Same as u_terminateUChars() but for a different string type. |
michael@0 | 243 | */ |
michael@0 | 244 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 245 | u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); |
michael@0 | 246 | |
michael@0 | 247 | #endif |