summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/collationtailoring.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /intl/icu/source/i18n/collationtailoring.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/icu/source/i18n/collationtailoring.h')
-rw-r--r--intl/icu/source/i18n/collationtailoring.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/collationtailoring.h b/intl/icu/source/i18n/collationtailoring.h
new file mode 100644
index 0000000000..ed7e46e3b9
--- /dev/null
+++ b/intl/icu/source/i18n/collationtailoring.h
@@ -0,0 +1,117 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+/*
+*******************************************************************************
+* Copyright (C) 2013-2014, International Business Machines
+* Corporation and others. All Rights Reserved.
+*******************************************************************************
+* collationtailoring.h
+*
+* created on: 2013mar12
+* created by: Markus W. Scherer
+*/
+
+#ifndef __COLLATIONTAILORING_H__
+#define __COLLATIONTAILORING_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_COLLATION
+
+#include "unicode/locid.h"
+#include "unicode/unistr.h"
+#include "unicode/uversion.h"
+#include "collationsettings.h"
+#include "uhash.h"
+#include "umutex.h"
+#include "unifiedcache.h"
+
+
+struct UDataMemory;
+struct UResourceBundle;
+struct UTrie2;
+
+U_NAMESPACE_BEGIN
+
+struct CollationData;
+
+class UnicodeSet;
+
+/**
+ * Collation tailoring data & settings.
+ * This is a container of values for a collation tailoring
+ * built from rules or deserialized from binary data.
+ *
+ * It is logically immutable: Do not modify its values.
+ * The fields are public for convenience.
+ *
+ * It is shared, reference-counted, and auto-deleted; see SharedObject.
+ */
+struct U_I18N_API CollationTailoring : public SharedObject {
+ CollationTailoring(const CollationSettings *baseSettings);
+ virtual ~CollationTailoring();
+
+ /**
+ * Returns true if the constructor could not initialize properly.
+ */
+ UBool isBogus() { return settings == nullptr; }
+
+ UBool ensureOwnedData(UErrorCode &errorCode);
+
+ static void makeBaseVersion(const UVersionInfo ucaVersion, UVersionInfo version);
+ void setVersion(const UVersionInfo baseVersion, const UVersionInfo rulesVersion);
+ int32_t getUCAVersion() const;
+
+ // data for sorting etc.
+ const CollationData *data; // == base data or ownedData
+ const CollationSettings *settings; // reference-counted
+ UnicodeString rules;
+ // The locale is bogus when built from rules or constructed from a binary blob.
+ // It can then be set by the service registration code which is thread-safe.
+ mutable Locale actualLocale;
+ // UCA version u.v.w & rules version r.s.t.q:
+ // version[0]: builder version (runtime version is mixed in at runtime)
+ // version[1]: bits 7..3=u, bits 2..0=v
+ // version[2]: bits 7..6=w, bits 5..0=r
+ // version[3]= (s<<5)+(s>>3)+t+(q<<4)+(q>>4)
+ UVersionInfo version;
+
+ // owned objects
+ CollationData *ownedData;
+ UObject *builder;
+ UDataMemory *memory;
+ UResourceBundle *bundle;
+ UTrie2 *trie;
+ UnicodeSet *unsafeBackwardSet;
+ mutable UHashtable *maxExpansions;
+ mutable UInitOnce maxExpansionsInitOnce;
+
+private:
+ /**
+ * No copy constructor: A CollationTailoring cannot be copied.
+ * It is immutable, and the data trie cannot be copied either.
+ */
+ CollationTailoring(const CollationTailoring &other) = delete;
+};
+
+struct U_I18N_API CollationCacheEntry : public SharedObject {
+ CollationCacheEntry(const Locale &loc, const CollationTailoring *t)
+ : validLocale(loc), tailoring(t) {
+ if(t != nullptr) {
+ t->addRef();
+ }
+ }
+ ~CollationCacheEntry();
+
+ Locale validLocale;
+ const CollationTailoring *tailoring;
+};
+
+template<> U_I18N_API
+const CollationCacheEntry *
+LocaleCacheKey<CollationCacheEntry>::createObject(const void *creationContext,
+ UErrorCode &errorCode) const;
+U_NAMESPACE_END
+
+#endif // !UCONFIG_NO_COLLATION
+#endif // __COLLATIONTAILORING_H__