1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2013-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * created on: 2013mar12
11 * created by: Markus W. Scherer
14 #ifndef __COLLATIONTAILORING_H__
15 #define __COLLATIONTAILORING_H__
17 #include "unicode/utypes.h"
19 #if !UCONFIG_NO_COLLATION
21 #include "unicode/locid.h"
22 #include "unicode/unistr.h"
23 #include "unicode/uversion.h"
24 #include "collationsettings.h"
29 struct UResourceBundle
;
39 * Collation tailoring data & settings.
40 * This is a container of values for a collation tailoring
41 * built from rules or deserialized from binary data.
43 * It is logically immutable: Do not modify its values.
44 * The fields are public for convenience.
46 * It is shared, reference-counted, and auto-deleted; see SharedObject.
48 struct U_I18N_API CollationTailoring
: public SharedObject
{
49 CollationTailoring(const CollationSettings
*baseSettings
);
50 virtual ~CollationTailoring();
53 * Returns TRUE if the constructor could not initialize properly.
55 UBool
isBogus() { return settings
== NULL
; }
57 UBool
ensureOwnedData(UErrorCode
&errorCode
);
59 static void makeBaseVersion(const UVersionInfo ucaVersion
, UVersionInfo version
);
60 void setVersion(const UVersionInfo baseVersion
, const UVersionInfo rulesVersion
);
61 int32_t getUCAVersion() const;
63 // data for sorting etc.
64 const CollationData
*data
; // == base data or ownedData
65 const CollationSettings
*settings
; // reference-counted
67 // The locale is bogus when built from rules or constructed from a binary blob.
68 // It can then be set by the service registration code which is thread-safe.
69 mutable Locale actualLocale
;
70 // UCA version u.v.w & rules version r.s.t.q:
71 // version[0]: builder version (runtime version is mixed in at runtime)
72 // version[1]: bits 7..3=u, bits 2..0=v
73 // version[2]: bits 7..6=w, bits 5..0=r
74 // version[3]= (s<<5)+(s>>3)+t+(q<<4)+(q>>4)
78 CollationData
*ownedData
;
81 UResourceBundle
*bundle
;
83 UnicodeSet
*unsafeBackwardSet
;
84 mutable UHashtable
*maxExpansions
;
85 mutable UInitOnce maxExpansionsInitOnce
;
89 * No copy constructor: A CollationTailoring cannot be copied.
90 * It is immutable, and the data trie cannot be copied either.
92 CollationTailoring(const CollationTailoring
&other
);
95 struct CollationCacheEntry
: public SharedObject
{
96 CollationCacheEntry(const Locale
&loc
, const CollationTailoring
*t
)
97 : validLocale(loc
), tailoring(t
) {
102 ~CollationCacheEntry();
105 const CollationTailoring
*tailoring
;
110 #endif // !UCONFIG_NO_COLLATION
111 #endif // __COLLATIONTAILORING_H__