OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 2010-2014, International Business Machines | 3 * Copyright (C) 2010-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 * collation.h | 6 * collation.h |
7 * | 7 * |
8 * created on: 2010oct27 | 8 * created on: 2010oct27 |
9 * created by: Markus W. Scherer | 9 * created by: Markus W. Scherer |
10 */ | 10 */ |
11 | 11 |
12 #ifndef __COLLATION_H__ | 12 #ifndef __COLLATION_H__ |
13 #define __COLLATION_H__ | 13 #define __COLLATION_H__ |
14 | 14 |
15 #include "unicode/utypes.h" | 15 #include "unicode/utypes.h" |
16 | 16 |
17 #if !UCONFIG_NO_COLLATION | 17 #if !UCONFIG_NO_COLLATION |
18 | 18 |
19 U_NAMESPACE_BEGIN | 19 U_NAMESPACE_BEGIN |
20 | 20 |
21 /** | 21 /** |
22 * Collation v2 basic definitions and static helper functions. | 22 * Collation v2 basic definitions and static helper functions. |
23 * | 23 * |
24 * Data structures except for expansion tables store 32-bit CEs which are | 24 * Data structures except for expansion tables store 32-bit CEs which are |
25 * either specials (see tags below) or are compact forms of 64-bit CEs. | 25 * either specials (see tags below) or are compact forms of 64-bit CEs. |
26 */ | 26 */ |
27 class U_I18N_API Collation { | 27 class U_I18N_API Collation { |
28 public: | 28 public: |
29 // Special sort key bytes for all levels. | 29 // Special sort key bytes for all levels. |
30 static const uint8_t TERMINATOR_BYTE = 0; | 30 static const uint8_t TERMINATOR_BYTE = 0; |
31 static const uint8_t LEVEL_SEPARATOR_BYTE = 1; | 31 static const uint8_t LEVEL_SEPARATOR_BYTE = 1; |
| 32 |
| 33 /** The secondary/tertiary lower limit for tailoring before any root element
s. */ |
| 34 static const uint32_t BEFORE_WEIGHT16 = 0x0100; |
| 35 |
32 /** | 36 /** |
33 * Merge-sort-key separator. | 37 * Merge-sort-key separator. |
34 * Must not be used as the lead byte of any CE weight, | 38 * Same as the unique primary and identical-level weights of U+FFFE. |
35 * nor as primary compression low terminator. | 39 * Must not be used as primary compression low terminator. |
36 * Otherwise usable. | 40 * Otherwise usable. |
37 */ | 41 */ |
38 static const uint8_t MERGE_SEPARATOR_BYTE = 2; | 42 static const uint8_t MERGE_SEPARATOR_BYTE = 2; |
39 static const uint32_t MERGE_SEPARATOR_PRIMARY = 0x02000000; // U+FFFE | 43 static const uint32_t MERGE_SEPARATOR_PRIMARY = 0x02000000; // U+FFFE |
40 static const uint32_t MERGE_SEPARATOR_WEIGHT16 = 0x0200; // U+FFFE | 44 static const uint32_t MERGE_SEPARATOR_CE32 = 0x02000505; // U+FFFE |
41 static const uint32_t MERGE_SEPARATOR_LOWER32 = 0x02000200; // U+FFFE | |
42 static const uint32_t MERGE_SEPARATOR_CE32 = 0x02000202; // U+FFFE | |
43 | 45 |
44 /** | 46 /** |
45 * Primary compression low terminator, must be greater than MERGE_SEPARATOR_
BYTE. | 47 * Primary compression low terminator, must be greater than MERGE_SEPARATOR_
BYTE. |
46 * Reserved value in primary second byte if the lead byte is compressible. | 48 * Reserved value in primary second byte if the lead byte is compressible. |
47 * Otherwise usable in all CE weight bytes. | 49 * Otherwise usable in all CE weight bytes. |
48 */ | 50 */ |
49 static const uint8_t PRIMARY_COMPRESSION_LOW_BYTE = 3; | 51 static const uint8_t PRIMARY_COMPRESSION_LOW_BYTE = 3; |
50 /** | 52 /** |
51 * Primary compression high terminator. | 53 * Primary compression high terminator. |
52 * Reserved value in primary second byte if the lead byte is compressible. | 54 * Reserved value in primary second byte if the lead byte is compressible. |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 481 |
480 /** | 482 /** |
481 * Returns the unassigned-character implicit primary weight for any valid co
de point c. | 483 * Returns the unassigned-character implicit primary weight for any valid co
de point c. |
482 */ | 484 */ |
483 static uint32_t unassignedPrimaryFromCodePoint(UChar32 c); | 485 static uint32_t unassignedPrimaryFromCodePoint(UChar32 c); |
484 | 486 |
485 static inline int64_t unassignedCEFromCodePoint(UChar32 c) { | 487 static inline int64_t unassignedCEFromCodePoint(UChar32 c) { |
486 return makeCE(unassignedPrimaryFromCodePoint(c)); | 488 return makeCE(unassignedPrimaryFromCodePoint(c)); |
487 } | 489 } |
488 | 490 |
489 static inline uint32_t reorder(const uint8_t reorderTable[256], uint32_t pri
mary) { | |
490 return ((uint32_t)reorderTable[primary >> 24] << 24) | (primary & 0xffff
ff); | |
491 } | |
492 | |
493 private: | 491 private: |
494 Collation(); // No instantiation. | 492 Collation(); // No instantiation. |
495 }; | 493 }; |
496 | 494 |
497 U_NAMESPACE_END | 495 U_NAMESPACE_END |
498 | 496 |
499 #endif // !UCONFIG_NO_COLLATION | 497 #endif // !UCONFIG_NO_COLLATION |
500 #endif // __COLLATION_H__ | 498 #endif // __COLLATION_H__ |
OLD | NEW |