1 // © 2017 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * 6 * Copyright (C) 2003, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 * 9 ******************************************************************************* 10 * 11 * File line.h 12 * 13 * Modification History: 14 * 15 * Date Name Description 16 * 07/07/2003 weiv Creation. 17 ******************************************************************************* 18 */ 19 20 // 21 // class Line 22 // 23 // Each line from the source file (containing a name, presumably) gets 24 // one of these structs. 25 // 26 27 #ifndef COLPROBE_STRENGTHPROBE_H 28 #define COLPROBE_STRENGTHPROBE_H 29 30 #include "colprobe.h" 31 #include "line.h" 32 #include "unicode/uniset.h" 33 #include "unicode/usetiter.h" 34 35 class StrengthProbe { 36 public: 37 UChar SE; 38 UChar B0; 39 UChar B1; 40 UChar B2; 41 UChar B3; 42 private: 43 Line utilFirst; 44 Line utilSecond; 45 Line *utilFirstP; 46 Line *utilSecondP; 47 Line contractionUtilFirst; 48 Line contractionUtilSecond; 49 UBool probePrefix(const Line &x, const Line &y, UChar first, UChar second); 50 UBool probeSuffix(const Line &x, const Line &y, UChar first, UChar second); 51 UBool probePrefixNoSep(const Line &x, const Line &y, UChar first, UChar second); 52 UBool probeSuffixNoSep(const Line &x, const Line &y, UChar first, UChar second); 53 54 UBool frenchSecondary; 55 56 public: 57 CompareFn comparer; 58 GetSortKeyFn skgetter; 59 StrengthProbe()60 StrengthProbe() {}; 61 StrengthProbe(CompareFn comparer, GetSortKeyFn getter, UChar SE = 0x0030, UChar B0 = 0x0061, UChar B1 = 0x0062, UChar B2 = 0x00E1, UChar B3 = 0x0041); //, UChar LB = 0x0039, UChar UB = 0xfa29); 62 int setProbeChars(UChar B0, UChar B1, UChar B2, UChar B3); 63 int checkSanity(); 64 StrengthProbe(const StrengthProbe &that); 65 StrengthProbe &operator=(const StrengthProbe &that); 66 UColAttributeValue getStrength(const Line &x, const Line &y); 67 UColAttributeValue getStrength(const UnicodeString &x, const UnicodeString &y); 68 UColAttributeValue getPrefixedStrength(const Line &prefix, const Line &x, const Line &y); 69 int32_t compare(const UnicodeString &x, const UnicodeString &y); 70 int32_t compare(const Line &x, const Line &y); 71 UColAttributeValue distanceFromEmptyString(const Line &x); 72 UColAttributeValue distanceFromEmptyString(const UnicodeString &x); 73 UBool isFrenchSecondary(UErrorCode &status); 74 UBool isUpperFirst(UErrorCode &status); getSortKey(const Line & l,uint8_t * buffer,int32_t buffCap)75 int getSortKey(const Line &l, uint8_t *buffer, int32_t buffCap) { 76 return skgetter(l.name, l.len, buffer, buffCap); 77 }; 78 getSortKey(UChar * string,int32_t sLen,uint8_t * buffer,int32_t buffCap)79 int getSortKey(UChar *string, int32_t sLen, uint8_t *buffer, int32_t buffCap) { 80 return skgetter(string, sLen, buffer, buffCap); 81 }; 82 83 }; 84 85 86 #endif //#ifndef COLPROBE_STRENGTHPROBE_H 87 88