]>
Commit | Line | Data |
---|---|---|
57a6839d A |
1 | /* |
2 | ******************************************************************************* | |
3 | * Copyright (C) 2013-2014, International Business Machines | |
4 | * Corporation and others. All Rights Reserved. | |
5 | ******************************************************************************* | |
6 | * collationtailoring.h | |
7 | * | |
8 | * created on: 2013mar12 | |
9 | * created by: Markus W. Scherer | |
10 | */ | |
11 | ||
12 | #ifndef __COLLATIONTAILORING_H__ | |
13 | #define __COLLATIONTAILORING_H__ | |
14 | ||
15 | #include "unicode/utypes.h" | |
16 | ||
17 | #if !UCONFIG_NO_COLLATION | |
18 | ||
19 | #include "unicode/locid.h" | |
20 | #include "unicode/unistr.h" | |
21 | #include "unicode/uversion.h" | |
22 | #include "collationsettings.h" | |
23 | #include "uhash.h" | |
24 | #include "umutex.h" | |
25 | ||
26 | struct UDataMemory; | |
27 | struct UResourceBundle; | |
28 | struct UTrie2; | |
29 | ||
30 | U_NAMESPACE_BEGIN | |
31 | ||
32 | struct CollationData; | |
33 | ||
34 | class UnicodeSet; | |
35 | ||
36 | /** | |
37 | * Collation tailoring data & settings. | |
38 | * This is a container of values for a collation tailoring | |
39 | * built from rules or deserialized from binary data. | |
40 | * | |
41 | * It is logically immutable: Do not modify its values. | |
42 | * The fields are public for convenience. | |
43 | * | |
44 | * It is shared, reference-counted, and auto-deleted; see SharedObject. | |
45 | */ | |
46 | struct U_I18N_API CollationTailoring : public SharedObject { | |
47 | CollationTailoring(const CollationSettings *baseSettings); | |
48 | virtual ~CollationTailoring(); | |
49 | ||
50 | /** | |
51 | * Returns TRUE if the constructor could not initialize properly. | |
52 | */ | |
53 | UBool isBogus() { return settings == NULL; } | |
54 | ||
55 | UBool ensureOwnedData(UErrorCode &errorCode); | |
56 | ||
57 | static void makeBaseVersion(const UVersionInfo ucaVersion, UVersionInfo version); | |
58 | void setVersion(const UVersionInfo baseVersion, const UVersionInfo rulesVersion); | |
59 | int32_t getUCAVersion() const; | |
60 | ||
61 | // data for sorting etc. | |
62 | const CollationData *data; // == base data or ownedData | |
63 | const CollationSettings *settings; // reference-counted | |
64 | UnicodeString rules; | |
65 | // The locale is bogus when built from rules or constructed from a binary blob. | |
66 | // It can then be set by the service registration code which is thread-safe. | |
67 | mutable Locale actualLocale; | |
68 | // UCA version u.v.w & rules version r.s.t.q: | |
69 | // version[0]: builder version (runtime version is mixed in at runtime) | |
70 | // version[1]: bits 7..3=u, bits 2..0=v | |
71 | // version[2]: bits 7..6=w, bits 5..0=r | |
72 | // version[3]= (s<<5)+(s>>3)+t+(q<<4)+(q>>4) | |
73 | UVersionInfo version; | |
74 | ||
75 | // owned objects | |
76 | CollationData *ownedData; | |
77 | UObject *builder; | |
78 | UDataMemory *memory; | |
79 | UResourceBundle *bundle; | |
80 | UTrie2 *trie; | |
81 | UnicodeSet *unsafeBackwardSet; | |
82 | mutable UHashtable *maxExpansions; | |
83 | mutable UInitOnce maxExpansionsInitOnce; | |
84 | ||
85 | private: | |
86 | /** | |
87 | * No copy constructor: A CollationTailoring cannot be copied. | |
88 | * It is immutable, and the data trie cannot be copied either. | |
89 | */ | |
90 | CollationTailoring(const CollationTailoring &other); | |
91 | }; | |
92 | ||
b331163b A |
93 | struct CollationCacheEntry : public SharedObject { |
94 | CollationCacheEntry(const Locale &loc, const CollationTailoring *t) | |
95 | : validLocale(loc), tailoring(t) { | |
96 | if(t != NULL) { | |
97 | t->addRef(); | |
98 | } | |
99 | } | |
100 | ~CollationCacheEntry(); | |
101 | ||
102 | Locale validLocale; | |
103 | const CollationTailoring *tailoring; | |
104 | }; | |
105 | ||
57a6839d A |
106 | U_NAMESPACE_END |
107 | ||
108 | #endif // !UCONFIG_NO_COLLATION | |
109 | #endif // __COLLATIONTAILORING_H__ |