2 *******************************************************************************
3 * Copyright (C) 2013-2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
8 * created on: 2013mar12
9 * created by: Markus W. Scherer
12 #ifndef __COLLATIONTAILORING_H__
13 #define __COLLATIONTAILORING_H__
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_COLLATION
19 #include "unicode/locid.h"
20 #include "unicode/unistr.h"
21 #include "unicode/uversion.h"
22 #include "collationsettings.h"
27 struct UResourceBundle
;
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.
41 * It is logically immutable: Do not modify its values.
42 * The fields are public for convenience.
44 * It is shared, reference-counted, and auto-deleted; see SharedObject.
46 struct U_I18N_API CollationTailoring
: public SharedObject
{
47 CollationTailoring(const CollationSettings
*baseSettings
);
48 virtual ~CollationTailoring();
51 * Returns TRUE if the constructor could not initialize properly.
53 UBool
isBogus() { return settings
== NULL
; }
55 UBool
ensureOwnedData(UErrorCode
&errorCode
);
57 static void makeBaseVersion(const UVersionInfo ucaVersion
, UVersionInfo version
);
58 void setVersion(const UVersionInfo baseVersion
, const UVersionInfo rulesVersion
);
59 int32_t getUCAVersion() const;
61 // data for sorting etc.
62 const CollationData
*data
; // == base data or ownedData
63 const CollationSettings
*settings
; // reference-counted
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)
76 CollationData
*ownedData
;
79 UResourceBundle
*bundle
;
81 UnicodeSet
*unsafeBackwardSet
;
82 mutable UHashtable
*maxExpansions
;
83 mutable UInitOnce maxExpansionsInitOnce
;
87 * No copy constructor: A CollationTailoring cannot be copied.
88 * It is immutable, and the data trie cannot be copied either.
90 CollationTailoring(const CollationTailoring
&other
);
93 struct CollationCacheEntry
: public SharedObject
{
94 CollationCacheEntry(const Locale
&loc
, const CollationTailoring
*t
)
95 : validLocale(loc
), tailoring(t
) {
100 ~CollationCacheEntry();
103 const CollationTailoring
*tailoring
;
108 #endif // !UCONFIG_NO_COLLATION
109 #endif // __COLLATIONTAILORING_H__