clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ucol.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/maurizio/node-v18.6.0/out -resource-dir /usr/local/lib/clang/16.0.0 -D V8_DEPRECATION_WARNINGS -D V8_IMMINENT_DEPRECATION_WARNINGS -D _GLIBCXX_USE_CXX11_ABI=1 -D NODE_OPENSSL_CONF_NAME=nodejs_conf -D NODE_OPENSSL_HAS_QUIC -D __STDC_FORMAT_MACROS -D OPENSSL_NO_PINSHARED -D OPENSSL_THREADS -D U_COMMON_IMPLEMENTATION=1 -D U_I18N_IMPLEMENTATION=1 -D U_IO_IMPLEMENTATION=1 -D U_TOOLUTIL_IMPLEMENTATION=1 -D U_ATTRIBUTE_DEPRECATED= -D _CRT_SECURE_NO_DEPRECATE= -D U_STATIC_IMPLEMENTATION=1 -D UCONFIG_NO_SERVICE=1 -D U_ENABLE_DYLOAD=0 -D U_HAVE_STD_STRING=1 -D UCONFIG_NO_BREAK_ITERATION=0 -I ../deps/icu-small/source/common -I ../deps/icu-small/source/i18n -I ../deps/icu-small/source/tools/toolutil -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward -internal-isystem /usr/local/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-parameter -Wno-deprecated-declarations -Wno-strict-aliasing -std=gnu++17 -fdeprecated-macro -fdebug-compilation-dir=/home/maurizio/node-v18.6.0/out -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-08-22-142216-507842-1 -x c++ ../deps/icu-small/source/i18n/ucol.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | #include "unicode/utypes.h" |
| 23 | |
| 24 | #if !UCONFIG_NO_COLLATION |
| 25 | |
| 26 | #include "unicode/coll.h" |
| 27 | #include "unicode/tblcoll.h" |
| 28 | #include "unicode/bytestream.h" |
| 29 | #include "unicode/coleitr.h" |
| 30 | #include "unicode/ucoleitr.h" |
| 31 | #include "unicode/ustring.h" |
| 32 | #include "cmemory.h" |
| 33 | #include "collation.h" |
| 34 | #include "cstring.h" |
| 35 | #include "putilimp.h" |
| 36 | #include "uassert.h" |
| 37 | #include "utracimp.h" |
| 38 | |
| 39 | U_NAMESPACE_USE |
| 40 | |
| 41 | U_CAPI UCollator* U_EXPORT2 |
| 42 | ucol_openBinary(const uint8_t *bin, int32_t length, |
| 43 | const UCollator *base, |
| 44 | UErrorCode *status) |
| 45 | { |
| 46 | if(U_FAILURE(*status)) { return NULL; } |
| 47 | RuleBasedCollator *coll = new RuleBasedCollator( |
| 48 | bin, length, |
| 49 | RuleBasedCollator::rbcFromUCollator(base), |
| 50 | *status); |
| 51 | if(coll == NULL) { |
| 52 | *status = U_MEMORY_ALLOCATION_ERROR; |
| 53 | return NULL; |
| 54 | } |
| 55 | if(U_FAILURE(*status)) { |
| 56 | delete coll; |
| 57 | return NULL; |
| 58 | } |
| 59 | return coll->toUCollator(); |
| 60 | } |
| 61 | |
| 62 | U_CAPI int32_t U_EXPORT2 |
| 63 | ucol_cloneBinary(const UCollator *coll, |
| 64 | uint8_t *buffer, int32_t capacity, |
| 65 | UErrorCode *status) |
| 66 | { |
| 67 | if(U_FAILURE(*status)) { |
| 68 | return 0; |
| 69 | } |
| 70 | const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll); |
| 71 | if(rbc == NULL && coll != NULL) { |
| 72 | *status = U_UNSUPPORTED_ERROR; |
| 73 | return 0; |
| 74 | } |
| 75 | return rbc->cloneBinary(buffer, capacity, *status); |
| 76 | } |
| 77 | |
| 78 | U_CAPI UCollator* U_EXPORT2 |
| 79 | ucol_safeClone(const UCollator *coll, void * , int32_t * pBufferSize, UErrorCode *status) |
| 80 | { |
| 81 | if (status == NULL || U_FAILURE(*status)){ |
| 82 | return NULL; |
| 83 | } |
| 84 | if (coll == NULL) { |
| 85 | *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 86 | return NULL; |
| 87 | } |
| 88 | if (pBufferSize != NULL) { |
| 89 | int32_t inputSize = *pBufferSize; |
| 90 | *pBufferSize = 1; |
| 91 | if (inputSize == 0) { |
| 92 | return NULL; |
| 93 | } |
| 94 | } |
| 95 | Collator *newColl = Collator::fromUCollator(coll)->clone(); |
| 96 | if (newColl == NULL) { |
| 97 | *status = U_MEMORY_ALLOCATION_ERROR; |
| 98 | return nullptr; |
| 99 | } else if (pBufferSize != NULL) { |
| 100 | *status = U_SAFECLONE_ALLOCATED_WARNING; |
| 101 | } |
| 102 | return newColl->toUCollator(); |
| 103 | } |
| 104 | |
| 105 | U_CAPI UCollator* U_EXPORT2 |
| 106 | ucol_clone(const UCollator *coll, UErrorCode *status) |
| 107 | { |
| 108 | return ucol_safeClone(coll, nullptr, nullptr, status); |
| 109 | } |
| 110 | |
| 111 | U_CAPI void U_EXPORT2 |
| 112 | ucol_close(UCollator *coll) |
| 113 | { |
| 114 | UTRACE_ENTRY_OC(UTRACE_UCOL_CLOSE); |
| 115 | UTRACE_DATA1(UTRACE_INFO, "coll = %p", coll); |
| 116 | if(coll != NULL) { |
| 117 | delete Collator::fromUCollator(coll); |
| 118 | } |
| 119 | UTRACE_EXIT(); |
| 120 | } |
| 121 | |
| 122 | U_CAPI int32_t U_EXPORT2 |
| 123 | ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, |
| 124 | const uint8_t *src2, int32_t src2Length, |
| 125 | uint8_t *dest, int32_t destCapacity) { |
| 126 | |
| 127 | if( src1==NULL || src1Length<-1 || src1Length==0 || (src1Length>0 && src1[src1Length-1]!=0) || |
| 128 | src2==NULL || src2Length<-1 || src2Length==0 || (src2Length>0 && src2[src2Length-1]!=0) || |
| 129 | destCapacity<0 || (destCapacity>0 && dest==NULL) |
| 130 | ) { |
| 131 | |
| 132 | if(dest!=NULL && destCapacity>0) { |
| 133 | *dest=0; |
| 134 | } |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | if(src1Length<0) { |
| 140 | src1Length=(int32_t)uprv_strlen((const char *)src1)+1; |
| 141 | } |
| 142 | if(src2Length<0) { |
| 143 | src2Length=(int32_t)uprv_strlen((const char *)src2)+1; |
| 144 | } |
| 145 | |
| 146 | int32_t destLength=src1Length+src2Length; |
| 147 | if(destLength>destCapacity) { |
| 148 | |
| 149 | return destLength; |
| 150 | } |
| 151 | |
| 152 | |
| 153 | uint8_t *p=dest; |
| 154 | for(;;) { |
| 155 | |
| 156 | uint8_t b; |
| 157 | while((b=*src1)>=2) { |
| 158 | ++src1; |
| 159 | *p++=b; |
| 160 | } |
| 161 | |
| 162 | |
| 163 | *p++=2; |
| 164 | |
| 165 | |
| 166 | while((b=*src2)>=2) { |
| 167 | ++src2; |
| 168 | *p++=b; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | if(*src1==1 && *src2==1) { |
| 173 | ++src1; |
| 174 | ++src2; |
| 175 | *p++=1; |
| 176 | } else { |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | if(*src1!=0) { |
| 187 | |
| 188 | src2=src1; |
| 189 | } |
| 190 | |
| 191 | while((*p++=*src2++)!=0) {} |
| 192 | |
| 193 | |
| 194 | return (int32_t)(p-dest); |
| 195 | } |
| 196 | |
| 197 | U_CAPI int32_t U_EXPORT2 |
| 198 | ucol_getSortKey(const UCollator *coll, |
| 199 | const UChar *source, |
| 200 | int32_t sourceLength, |
| 201 | uint8_t *result, |
| 202 | int32_t resultLength) |
| 203 | { |
| 204 | UTRACE_ENTRY(UTRACE_UCOL_GET_SORTKEY); |
| 205 | if (UTRACE_LEVEL(UTRACE_VERBOSE)) { |
| 206 | UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source string = %vh ", coll, source, |
| 207 | ((sourceLength==-1 && source!=NULL) ? u_strlen(source) : sourceLength)); |
| 208 | } |
| 209 | |
| 210 | int32_t keySize = Collator::fromUCollator(coll)-> |
| 211 | getSortKey(source, sourceLength, result, resultLength); |
| 212 | |
| 213 | UTRACE_DATA2(UTRACE_VERBOSE, "Sort Key = %vb", result, keySize); |
| 214 | UTRACE_EXIT_VALUE(keySize); |
| 215 | return keySize; |
| 216 | } |
| 217 | |
| 218 | U_CAPI int32_t U_EXPORT2 |
| 219 | ucol_nextSortKeyPart(const UCollator *coll, |
| 220 | UCharIterator *iter, |
| 221 | uint32_t state[2], |
| 222 | uint8_t *dest, int32_t count, |
| 223 | UErrorCode *status) |
| 224 | { |
| 225 | |
| 226 | if(status==NULL || U_FAILURE(*status)) { |
| 227 | return 0; |
| 228 | } |
| 229 | UTRACE_ENTRY(UTRACE_UCOL_NEXTSORTKEYPART); |
| 230 | UTRACE_DATA6(UTRACE_VERBOSE, "coll=%p, iter=%p, state=%d %d, dest=%p, count=%d", |
| 231 | coll, iter, state[0], state[1], dest, count); |
| 232 | |
| 233 | int32_t i = Collator::fromUCollator(coll)-> |
| 234 | internalNextSortKeyPart(iter, state, dest, count, *status); |
| 235 | |
| 236 | |
| 237 | UTRACE_DATA4(UTRACE_VERBOSE, "dest = %vb, state=%d %d", |
| 238 | dest,i, state[0], state[1]); |
| 239 | UTRACE_EXIT_VALUE_STATUS(i, *status); |
| 240 | return i; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | U_CAPI int32_t U_EXPORT2 |
| 247 | ucol_getBound(const uint8_t *source, |
| 248 | int32_t sourceLength, |
| 249 | UColBoundMode boundType, |
| 250 | uint32_t noOfLevels, |
| 251 | uint8_t *result, |
| 252 | int32_t resultLength, |
| 253 | UErrorCode *status) |
| 254 | { |
| 255 | |
| 256 | if(status == NULL || U_FAILURE(*status)) { |
| 257 | return 0; |
| 258 | } |
| 259 | if(source == NULL) { |
| 260 | *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | int32_t sourceIndex = 0; |
| 265 | |
| 266 | do { |
| 267 | sourceIndex++; |
| 268 | if(source[sourceIndex] == Collation::LEVEL_SEPARATOR_BYTE) { |
| 269 | noOfLevels--; |
| 270 | } |
| 271 | } while (noOfLevels > 0 |
| 272 | && (source[sourceIndex] != 0 || sourceIndex < sourceLength)); |
| 273 | |
| 274 | if((source[sourceIndex] == 0 || sourceIndex == sourceLength) |
| 275 | && noOfLevels > 0) { |
| 276 | *status = U_SORT_KEY_TOO_SHORT_WARNING; |
| 277 | } |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | if(result != NULL && resultLength >= sourceIndex+boundType) { |
| 285 | uprv_memcpy(result, source, sourceIndex); |
| 286 | switch(boundType) { |
| 287 | |
| 288 | case UCOL_BOUND_LOWER: |
| 289 | break; |
| 290 | |
| 291 | case UCOL_BOUND_UPPER: |
| 292 | result[sourceIndex++] = 2; |
| 293 | break; |
| 294 | |
| 295 | case UCOL_BOUND_UPPER_LONG: |
| 296 | result[sourceIndex++] = 0xFF; |
| 297 | result[sourceIndex++] = 0xFF; |
| 298 | break; |
| 299 | default: |
| 300 | *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 301 | return 0; |
| 302 | } |
| 303 | result[sourceIndex++] = 0; |
| 304 | |
| 305 | return sourceIndex; |
| 306 | } else { |
| 307 | return sourceIndex+boundType+1; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | U_CAPI void U_EXPORT2 |
| 312 | ucol_setMaxVariable(UCollator *coll, UColReorderCode group, UErrorCode *pErrorCode) { |
| 313 | if(U_FAILURE(*pErrorCode)) { return; } |
| 314 | Collator::fromUCollator(coll)->setMaxVariable(group, *pErrorCode); |
| 315 | } |
| 316 | |
| 317 | U_CAPI UColReorderCode U_EXPORT2 |
| 318 | ucol_getMaxVariable(const UCollator *coll) { |
| 319 | return Collator::fromUCollator(coll)->getMaxVariable(); |
| 320 | } |
| 321 | |
| 322 | U_CAPI uint32_t U_EXPORT2 |
| 323 | ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status) { |
| 324 | if(U_FAILURE(*status) || coll == NULL) { |
| 325 | return 0; |
| 326 | } |
| 327 | return Collator::fromUCollator(coll)->setVariableTop(varTop, len, *status); |
| 328 | } |
| 329 | |
| 330 | U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status) { |
| 331 | if(U_FAILURE(*status) || coll == NULL) { |
| 332 | return 0; |
| 333 | } |
| 334 | return Collator::fromUCollator(coll)->getVariableTop(*status); |
| 335 | } |
| 336 | |
| 337 | U_CAPI void U_EXPORT2 |
| 338 | ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status) { |
| 339 | if(U_FAILURE(*status) || coll == NULL) { |
| 340 | return; |
| 341 | } |
| 342 | Collator::fromUCollator(coll)->setVariableTop(varTop, *status); |
| 343 | } |
| 344 | |
| 345 | U_CAPI void U_EXPORT2 |
| 346 | ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status) { |
| 347 | if(U_FAILURE(*status) || coll == NULL) { |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | Collator::fromUCollator(coll)->setAttribute(attr, value, *status); |
| 352 | } |
| 353 | |
| 354 | U_CAPI UColAttributeValue U_EXPORT2 |
| 355 | ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) { |
| 356 | if(U_FAILURE(*status) || coll == NULL) { |
| 357 | return UCOL_DEFAULT; |
| 358 | } |
| 359 | |
| 360 | return Collator::fromUCollator(coll)->getAttribute(attr, *status); |
| 361 | } |
| 362 | |
| 363 | U_CAPI void U_EXPORT2 |
| 364 | ucol_setStrength( UCollator *coll, |
| 365 | UCollationStrength strength) |
| 366 | { |
| 367 | UErrorCode status = U_ZERO_ERROR; |
| 368 | ucol_setAttribute(coll, UCOL_STRENGTH, strength, &status); |
| 369 | } |
| 370 | |
| 371 | U_CAPI UCollationStrength U_EXPORT2 |
| 372 | ucol_getStrength(const UCollator *coll) |
| 373 | { |
| 374 | UErrorCode status = U_ZERO_ERROR; |
| 375 | return ucol_getAttribute(coll, UCOL_STRENGTH, &status); |
| 376 | } |
| 377 | |
| 378 | U_CAPI int32_t U_EXPORT2 |
| 379 | ucol_getReorderCodes(const UCollator *coll, |
| 380 | int32_t *dest, |
| 381 | int32_t destCapacity, |
| 382 | UErrorCode *status) { |
| 383 | if (U_FAILURE(*status)) { |
| 384 | return 0; |
| 385 | } |
| 386 | |
| 387 | return Collator::fromUCollator(coll)->getReorderCodes(dest, destCapacity, *status); |
| 388 | } |
| 389 | |
| 390 | U_CAPI void U_EXPORT2 |
| 391 | ucol_setReorderCodes(UCollator* coll, |
| 392 | const int32_t* reorderCodes, |
| 393 | int32_t reorderCodesLength, |
| 394 | UErrorCode *status) { |
| 395 | if (U_FAILURE(*status)) { |
| 396 | return; |
| 397 | } |
| 398 | |
| 399 | Collator::fromUCollator(coll)->setReorderCodes(reorderCodes, reorderCodesLength, *status); |
| 400 | } |
| 401 | |
| 402 | U_CAPI int32_t U_EXPORT2 |
| 403 | ucol_getEquivalentReorderCodes(int32_t reorderCode, |
| 404 | int32_t* dest, |
| 405 | int32_t destCapacity, |
| 406 | UErrorCode *pErrorCode) { |
| 407 | return Collator::getEquivalentReorderCodes(reorderCode, dest, destCapacity, *pErrorCode); |
| 408 | } |
| 409 | |
| 410 | U_CAPI void U_EXPORT2 |
| 411 | ucol_getVersion(const UCollator* coll, |
| 412 | UVersionInfo versionInfo) |
| 413 | { |
| 414 | Collator::fromUCollator(coll)->getVersion(versionInfo); |
| 415 | } |
| 416 | |
| 417 | U_CAPI UCollationResult U_EXPORT2 |
| 418 | ucol_strcollIter( const UCollator *coll, |
| 419 | UCharIterator *sIter, |
| 420 | UCharIterator *tIter, |
| 421 | UErrorCode *status) |
| 422 | { |
| 423 | if(!status || U_FAILURE(*status)) { |
| 424 | return UCOL_EQUAL; |
| 425 | } |
| 426 | |
| 427 | UTRACE_ENTRY(UTRACE_UCOL_STRCOLLITER); |
| 428 | UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, sIter=%p, tIter=%p", coll, sIter, tIter); |
| 429 | |
| 430 | if(sIter == NULL || tIter == NULL || coll == NULL) { |
| 431 | *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 432 | UTRACE_EXIT_VALUE_STATUS(UCOL_EQUAL, *status); |
| 433 | return UCOL_EQUAL; |
| 434 | } |
| 435 | |
| 436 | UCollationResult result = Collator::fromUCollator(coll)->compare(*sIter, *tIter, *status); |
| 437 | |
| 438 | UTRACE_EXIT_VALUE_STATUS(result, *status); |
| 439 | return result; |
| 440 | } |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | U_CAPI UCollationResult U_EXPORT2 |
| 447 | ucol_strcoll( const UCollator *coll, |
| 448 | const UChar *source, |
| 449 | int32_t sourceLength, |
| 450 | const UChar *target, |
| 451 | int32_t targetLength) |
| 452 | { |
| 453 | UTRACE_ENTRY(UTRACE_UCOL_STRCOLL); |
| 454 | if (UTRACE_LEVEL(UTRACE_VERBOSE)) { |
| 455 | UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source=%p, target=%p", coll, source, target); |
| 456 | UTRACE_DATA2(UTRACE_VERBOSE, "source string = %vh ", source, sourceLength); |
| 457 | UTRACE_DATA2(UTRACE_VERBOSE, "target string = %vh ", target, targetLength); |
| 458 | } |
| 459 | |
| 460 | UErrorCode status = U_ZERO_ERROR; |
| 461 | UCollationResult returnVal = Collator::fromUCollator(coll)-> |
| 462 | compare(source, sourceLength, target, targetLength, status); |
| 463 | UTRACE_EXIT_VALUE_STATUS(returnVal, status); |
| 464 | return returnVal; |
| 465 | } |
| 466 | |
| 467 | U_CAPI UCollationResult U_EXPORT2 |
| 468 | ucol_strcollUTF8( |
| 469 | const UCollator *coll, |
| 470 | const char *source, |
| 471 | int32_t sourceLength, |
| 472 | const char *target, |
| 473 | int32_t targetLength, |
| 474 | UErrorCode *status) |
| 475 | { |
| 476 | UTRACE_ENTRY(UTRACE_UCOL_STRCOLLUTF8); |
| 477 | if (UTRACE_LEVEL(UTRACE_VERBOSE)) { |
| 478 | UTRACE_DATA3(UTRACE_VERBOSE, "coll=%p, source=%p, target=%p", coll, source, target); |
| 479 | UTRACE_DATA2(UTRACE_VERBOSE, "source string = %vb ", source, sourceLength); |
| 480 | UTRACE_DATA2(UTRACE_VERBOSE, "target string = %vb ", target, targetLength); |
| 481 | } |
| 482 | |
| 483 | if (U_FAILURE(*status)) { |
| 484 | |
| 485 | UTRACE_EXIT_VALUE_STATUS(UCOL_EQUAL, *status); |
| 486 | return UCOL_EQUAL; |
| 487 | } |
| 488 | |
| 489 | UCollationResult returnVal = Collator::fromUCollator(coll)->internalCompareUTF8( |
| 490 | source, sourceLength, target, targetLength, *status); |
| 491 | UTRACE_EXIT_VALUE_STATUS(returnVal, *status); |
| 492 | return returnVal; |
| 493 | } |
| 494 | |
| 495 | |
| 496 | |
| 497 | U_CAPI UBool U_EXPORT2 |
| 498 | ucol_greater( const UCollator *coll, |
| 499 | const UChar *source, |
| 500 | int32_t sourceLength, |
| 501 | const UChar *target, |
| 502 | int32_t targetLength) |
| 503 | { |
| 504 | return (ucol_strcoll(coll, source, sourceLength, target, targetLength) |
| 505 | == UCOL_GREATER); |
| 506 | } |
| 507 | |
| 508 | |
| 509 | U_CAPI UBool U_EXPORT2 |
| 510 | ucol_greaterOrEqual( const UCollator *coll, |
| 511 | const UChar *source, |
| 512 | int32_t sourceLength, |
| 513 | const UChar *target, |
| 514 | int32_t targetLength) |
| 515 | { |
| 516 | return (ucol_strcoll(coll, source, sourceLength, target, targetLength) |
| 517 | != UCOL_LESS); |
| 518 | } |
| 519 | |
| 520 | |
| 521 | U_CAPI UBool U_EXPORT2 |
| 522 | ucol_equal( const UCollator *coll, |
| 523 | const UChar *source, |
| 524 | int32_t sourceLength, |
| 525 | const UChar *target, |
| 526 | int32_t targetLength) |
| 527 | { |
| 528 | return (ucol_strcoll(coll, source, sourceLength, target, targetLength) |
| 529 | == UCOL_EQUAL); |
| 530 | } |
| 531 | |
| 532 | U_CAPI void U_EXPORT2 |
| 533 | ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) { |
| 534 | const Collator *c = Collator::fromUCollator(coll); |
| 535 | if(c != NULL) { |
| 536 | UVersionInfo v; |
| 537 | c->getVersion(v); |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | info[0] = v[1] >> 3; |
| 545 | info[1] = v[1] & 7; |
| 546 | info[2] = v[2] >> 6; |
| 547 | info[3] = 0; |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | U_CAPI const UChar * U_EXPORT2 |
| 552 | ucol_getRules(const UCollator *coll, int32_t *length) { |
| 553 | const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll); |
| 1 | Passing value via 1st parameter 'uc' | |
|
| 2 | | Calling 'RuleBasedCollator::rbcFromUCollator' | |
|
| 5 | | Returning from 'RuleBasedCollator::rbcFromUCollator' | |
|
| |
| 554 | |
| 555 | if(rbc != NULL || coll == NULL) { |
| 7 | | Assuming 'rbc' is equal to NULL | |
|
| |
| 556 | const UnicodeString &rules = rbc->getRules(); |
| 9 | | Called C++ object pointer is null |
|
| 557 | U_ASSERT(rules.getBuffer()[rules.length()] == 0); |
| 558 | *length = rules.length(); |
| 559 | return rules.getBuffer(); |
| 560 | } |
| 561 | static const UChar _NUL = 0; |
| 562 | *length = 0; |
| 563 | return &_NUL; |
| 564 | } |
| 565 | |
| 566 | U_CAPI int32_t U_EXPORT2 |
| 567 | ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen) { |
| 568 | UnicodeString rules; |
| 569 | const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll); |
| 570 | if(rbc != NULL || coll == NULL) { |
| 571 | rbc->getRules(delta, rules); |
| 572 | } |
| 573 | if(buffer != NULL && bufferLen > 0) { |
| 574 | UErrorCode errorCode = U_ZERO_ERROR; |
| 575 | return rules.extract(buffer, bufferLen, errorCode); |
| 576 | } else { |
| 577 | return rules.length(); |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | U_CAPI const char * U_EXPORT2 |
| 582 | ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status) { |
| 583 | return ucol_getLocaleByType(coll, type, status); |
| 584 | } |
| 585 | |
| 586 | U_CAPI const char * U_EXPORT2 |
| 587 | ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status) { |
| 588 | if(U_FAILURE(*status)) { |
| 589 | return NULL; |
| 590 | } |
| 591 | UTRACE_ENTRY(UTRACE_UCOL_GETLOCALE); |
| 592 | UTRACE_DATA1(UTRACE_INFO, "coll=%p", coll); |
| 593 | |
| 594 | const char *result; |
| 595 | const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll); |
| 596 | if(rbc == NULL && coll != NULL) { |
| 597 | *status = U_UNSUPPORTED_ERROR; |
| 598 | result = NULL; |
| 599 | } else { |
| 600 | result = rbc->internalGetLocaleID(type, *status); |
| 601 | } |
| 602 | |
| 603 | UTRACE_DATA1(UTRACE_INFO, "result = %s", result); |
| 604 | UTRACE_EXIT_STATUS(*status); |
| 605 | return result; |
| 606 | } |
| 607 | |
| 608 | U_CAPI USet * U_EXPORT2 |
| 609 | ucol_getTailoredSet(const UCollator *coll, UErrorCode *status) { |
| 610 | if(U_FAILURE(*status)) { |
| 611 | return NULL; |
| 612 | } |
| 613 | UnicodeSet *set = Collator::fromUCollator(coll)->getTailoredSet(*status); |
| 614 | if(U_FAILURE(*status)) { |
| 615 | delete set; |
| 616 | return NULL; |
| 617 | } |
| 618 | return set->toUSet(); |
| 619 | } |
| 620 | |
| 621 | U_CAPI UBool U_EXPORT2 |
| 622 | ucol_equals(const UCollator *source, const UCollator *target) { |
| 623 | return source == target || |
| 624 | (*Collator::fromUCollator(source)) == (*Collator::fromUCollator(target)); |
| 625 | } |
| 626 | |
| 627 | #endif /* #if !UCONFIG_NO_COLLATION */ |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | #ifndef TBLCOLL_H |
| 63 | #define TBLCOLL_H |
| 64 | |
| 65 | #include "unicode/utypes.h" |
| 66 | |
| 67 | #if U_SHOW_CPLUSPLUS_API |
| 68 | |
| 69 | #if !UCONFIG_NO_COLLATION |
| 70 | |
| 71 | #include "unicode/coll.h" |
| 72 | #include "unicode/locid.h" |
| 73 | #include "unicode/uiter.h" |
| 74 | #include "unicode/ucol.h" |
| 75 | |
| 76 | U_NAMESPACE_BEGIN |
| 77 | |
| 78 | struct CollationCacheEntry; |
| 79 | struct CollationData; |
| 80 | struct CollationSettings; |
| 81 | struct CollationTailoring; |
| 82 | |
| 83 | |
| 84 | |
| 85 | class StringSearch; |
| 86 | |
| 87 | |
| 88 | |
| 89 | class CollationElementIterator; |
| 90 | class CollationKey; |
| 91 | class SortKeyByteSink; |
| 92 | class UnicodeSet; |
| 93 | class UnicodeString; |
| 94 | class UVector64; |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | class U_I18N_API RuleBasedCollator U_FINAL : public Collator { |
| 116 | public: |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | RuleBasedCollator(const UnicodeString& rules, UErrorCode& status); |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | RuleBasedCollator(const UnicodeString& rules, |
| 137 | ECollationStrength collationStrength, |
| 138 | UErrorCode& status); |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | RuleBasedCollator(const UnicodeString& rules, |
| 150 | UColAttributeValue decompositionMode, |
| 151 | UErrorCode& status); |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | RuleBasedCollator(const UnicodeString& rules, |
| 164 | ECollationStrength collationStrength, |
| 165 | UColAttributeValue decompositionMode, |
| 166 | UErrorCode& status); |
| 167 | |
| 168 | #ifndef U_HIDE_INTERNAL_API |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | RuleBasedCollator(const UnicodeString &rules, |
| 174 | UParseError &parseError, UnicodeString &reason, |
| 175 | UErrorCode &errorCode); |
| 176 | #endif /* U_HIDE_INTERNAL_API */ |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | RuleBasedCollator(const RuleBasedCollator& other); |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | RuleBasedCollator(const uint8_t *bin, int32_t length, |
| 204 | const RuleBasedCollator *base, |
| 205 | UErrorCode &status); |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | virtual ~RuleBasedCollator(); |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | RuleBasedCollator& operator=(const RuleBasedCollator& other); |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | virtual bool operator==(const Collator& other) const override; |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | virtual RuleBasedCollator* clone() const override; |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | virtual CollationElementIterator* createCollationElementIterator( |
| 246 | const UnicodeString& source) const; |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | virtual CollationElementIterator* createCollationElementIterator( |
| 258 | const CharacterIterator& source) const; |
| 259 | |
| 260 | |
| 261 | using Collator::compare; |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | virtual UCollationResult compare(const UnicodeString& source, |
| 276 | const UnicodeString& target, |
| 277 | UErrorCode &status) const override; |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | virtual UCollationResult compare(const UnicodeString& source, |
| 293 | const UnicodeString& target, |
| 294 | int32_t length, |
| 295 | UErrorCode &status) const override; |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | virtual UCollationResult compare(const char16_t* source, int32_t sourceLength, |
| 314 | const char16_t* target, int32_t targetLength, |
| 315 | UErrorCode &status) const override; |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | virtual UCollationResult compare(UCharIterator &sIter, |
| 329 | UCharIterator &tIter, |
| 330 | UErrorCode &status) const override; |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | virtual UCollationResult compareUTF8(const StringPiece &source, |
| 346 | const StringPiece &target, |
| 347 | UErrorCode &status) const override; |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | virtual CollationKey& getCollationKey(const UnicodeString& source, |
| 364 | CollationKey& key, |
| 365 | UErrorCode& status) const override; |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | virtual CollationKey& getCollationKey(const char16_t *source, |
| 383 | int32_t sourceLength, |
| 384 | CollationKey& key, |
| 385 | UErrorCode& status) const override; |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | virtual int32_t hashCode() const override; |
| 393 | |
| 394 | #ifndef U_FORCE_HIDE_DEPRECATED_API |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const override; |
| 406 | #endif // U_FORCE_HIDE_DEPRECATED_API |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | const UnicodeString& getRules() const; |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | virtual void getVersion(UVersionInfo info) const override; |
| 421 | |
| 422 | #ifndef U_HIDE_DEPRECATED_API |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | int32_t getMaxExpansion(int32_t order) const; |
| 440 | #endif /* U_HIDE_DEPRECATED_API */ |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | virtual UClassID getDynamicClassID(void) const override; |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | static UClassID U_EXPORT2 getStaticClassID(void); |
| 466 | |
| 467 | #ifndef U_HIDE_DEPRECATED_API |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | uint8_t *cloneRuleData(int32_t &length, UErrorCode &status) const; |
| 479 | #endif /* U_HIDE_DEPRECATED_API */ |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status) const; |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | void getRules(UColRuleOption delta, UnicodeString &buffer) const; |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | virtual void setAttribute(UColAttribute attr, UColAttributeValue value, |
| 514 | UErrorCode &status) override; |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | virtual UColAttributeValue getAttribute(UColAttribute attr, |
| 524 | UErrorCode &status) const override; |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | virtual Collator &setMaxVariable(UColReorderCode group, UErrorCode &errorCode) override; |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | virtual UColReorderCode getMaxVariable() const override; |
| 551 | |
| 552 | #ifndef U_FORCE_HIDE_DEPRECATED_API |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | virtual uint32_t setVariableTop(const char16_t *varTop, int32_t len, UErrorCode &status) override; |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status) override; |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | |
| 599 | virtual void setVariableTop(uint32_t varTop, UErrorCode &status) override; |
| 600 | #endif // U_FORCE_HIDE_DEPRECATED_API |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | virtual uint32_t getVariableTop(UErrorCode &status) const override; |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | virtual UnicodeSet *getTailoredSet(UErrorCode &status) const override; |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result, |
| 637 | int32_t resultLength) const override; |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | virtual int32_t getSortKey(const char16_t *source, int32_t sourceLength, |
| 656 | uint8_t *result, int32_t resultLength) const override; |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | virtual int32_t getReorderCodes(int32_t *dest, |
| 672 | int32_t destCapacity, |
| 673 | UErrorCode& status) const override; |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | virtual void setReorderCodes(const int32_t* reorderCodes, |
| 687 | int32_t reorderCodesLength, |
| 688 | UErrorCode& status) override; |
| 689 | |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | virtual UCollationResult internalCompareUTF8( |
| 695 | const char *left, int32_t leftLength, |
| 696 | const char *right, int32_t rightLength, |
| 697 | UErrorCode &errorCode) const override; |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | virtual int32_t internalGetShortDefinitionString(const char *locale, |
| 723 | char *buffer, |
| 724 | int32_t capacity, |
| 725 | UErrorCode &status) const override; |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | virtual int32_t internalNextSortKeyPart( |
| 732 | UCharIterator *iter, uint32_t state[2], |
| 733 | uint8_t *dest, int32_t count, UErrorCode &errorCode) const override; |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | RuleBasedCollator(); |
| 741 | |
| 742 | #ifndef U_HIDE_INTERNAL_API |
| 743 | |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | |
| 749 | const char *internalGetLocaleID(ULocDataLocaleType type, UErrorCode &errorCode) const; |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | void internalGetContractionsAndExpansions( |
| 764 | UnicodeSet *contractions, UnicodeSet *expansions, |
| 765 | UBool addPrefixes, UErrorCode &errorCode) const; |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | void internalAddContractions(UChar32 c, UnicodeSet &set, UErrorCode &errorCode) const; |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | void internalBuildTailoring( |
| 779 | const UnicodeString &rules, |
| 780 | int32_t strength, |
| 781 | UColAttributeValue decompositionMode, |
| 782 | UParseError *outParseError, UnicodeString *outReason, |
| 783 | UErrorCode &errorCode); |
| 784 | |
| 785 | |
| 786 | static inline RuleBasedCollator *rbcFromUCollator(UCollator *uc) { |
| 787 | return dynamic_cast<RuleBasedCollator *>(fromUCollator(uc)); |
| 788 | } |
| 789 | |
| 790 | static inline const RuleBasedCollator *rbcFromUCollator(const UCollator *uc) { |
| 791 | return dynamic_cast<const RuleBasedCollator *>(fromUCollator(uc)); |
| 3 | | Passing value via 1st parameter 'uc' | |
|
| |
| 792 | } |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | void internalGetCEs(const UnicodeString &str, UVector64 &ces, UErrorCode &errorCode) const; |
| 799 | #endif // U_HIDE_INTERNAL_API |
| 800 | |
| 801 | protected: |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale) override; |
| 810 | |
| 811 | private: |
| 812 | friend class CollationElementIterator; |
| 813 | friend class Collator; |
| 814 | |
| 815 | RuleBasedCollator(const CollationCacheEntry *entry); |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | enum Attributes { |
| 823 | ATTR_VARIABLE_TOP = UCOL_ATTRIBUTE_COUNT, |
| 824 | ATTR_LIMIT |
| 825 | }; |
| 826 | |
| 827 | void adoptTailoring(CollationTailoring *t, UErrorCode &errorCode); |
| 828 | |
| 829 | |
| 830 | UCollationResult doCompare(const char16_t *left, int32_t leftLength, |
| 831 | const char16_t *right, int32_t rightLength, |
| 832 | UErrorCode &errorCode) const; |
| 833 | UCollationResult doCompare(const uint8_t *left, int32_t leftLength, |
| 834 | const uint8_t *right, int32_t rightLength, |
| 835 | UErrorCode &errorCode) const; |
| 836 | |
| 837 | void writeSortKey(const char16_t *s, int32_t length, |
| 838 | SortKeyByteSink &sink, UErrorCode &errorCode) const; |
| 839 | |
| 840 | void writeIdenticalLevel(const char16_t *s, const char16_t *limit, |
| 841 | SortKeyByteSink &sink, UErrorCode &errorCode) const; |
| 842 | |
| 843 | const CollationSettings &getDefaultSettings() const; |
| 844 | |
| 845 | void setAttributeDefault(int32_t attribute) { |
| 846 | explicitlySetAttributes &= ~((uint32_t)1 << attribute); |
| 847 | } |
| 848 | void setAttributeExplicitly(int32_t attribute) { |
| 849 | explicitlySetAttributes |= (uint32_t)1 << attribute; |
| 850 | } |
| 851 | UBool attributeHasBeenSetExplicitly(int32_t attribute) const { |
| 852 | |
| 853 | return (UBool)((explicitlySetAttributes & ((uint32_t)1 << attribute)) != 0); |
| 854 | } |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | UBool isUnsafe(UChar32 c) const; |
| 864 | |
| 865 | static void U_CALLCONV computeMaxExpansions(const CollationTailoring *t, UErrorCode &errorCode); |
| 866 | UBool initMaxExpansions(UErrorCode &errorCode) const; |
| 867 | |
| 868 | void setFastLatinOptions(CollationSettings &ownedSettings) const; |
| 869 | |
| 870 | const CollationData *data; |
| 871 | const CollationSettings *settings; |
| 872 | const CollationTailoring *tailoring; |
| 873 | const CollationCacheEntry *cacheEntry; |
| 874 | Locale validLocale; |
| 875 | uint32_t explicitlySetAttributes; |
| 876 | |
| 877 | UBool actualLocaleIsSameAsValid; |
| 878 | }; |
| 879 | |
| 880 | U_NAMESPACE_END |
| 881 | |
| 882 | #endif // !UCONFIG_NO_COLLATION |
| 883 | |
| 884 | #endif /* U_SHOW_CPLUSPLUS_API */ |
| 885 | |
| 886 | #endif // TBLCOLL_H |