xref: /aosp_15_r20/external/icu/libicu/cts_headers/emojiprops.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2021 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: https://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker 
4*0e209d39SAndroid Build Coastguard Worker // emojiprops.h
5*0e209d39SAndroid Build Coastguard Worker // created: 2021sep03 Markus W. Scherer
6*0e209d39SAndroid Build Coastguard Worker 
7*0e209d39SAndroid Build Coastguard Worker #ifndef __EMOJIPROPS_H__
8*0e209d39SAndroid Build Coastguard Worker #define __EMOJIPROPS_H__
9*0e209d39SAndroid Build Coastguard Worker 
10*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
11*0e209d39SAndroid Build Coastguard Worker #include "unicode/ucptrie.h"
12*0e209d39SAndroid Build Coastguard Worker #include "unicode/udata.h"
13*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h"
14*0e209d39SAndroid Build Coastguard Worker #include "uset_imp.h"
15*0e209d39SAndroid Build Coastguard Worker 
16*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
17*0e209d39SAndroid Build Coastguard Worker 
18*0e209d39SAndroid Build Coastguard Worker class EmojiProps : public UMemory {
19*0e209d39SAndroid Build Coastguard Worker public:
20*0e209d39SAndroid Build Coastguard Worker     // @internal
EmojiProps(UErrorCode & errorCode)21*0e209d39SAndroid Build Coastguard Worker     EmojiProps(UErrorCode &errorCode) { load(errorCode); }
22*0e209d39SAndroid Build Coastguard Worker     ~EmojiProps();
23*0e209d39SAndroid Build Coastguard Worker 
24*0e209d39SAndroid Build Coastguard Worker     static const EmojiProps *getSingleton(UErrorCode &errorCode);
25*0e209d39SAndroid Build Coastguard Worker     static UBool hasBinaryProperty(UChar32 c, UProperty which);
26*0e209d39SAndroid Build Coastguard Worker     static UBool hasBinaryProperty(const char16_t *s, int32_t length, UProperty which);
27*0e209d39SAndroid Build Coastguard Worker 
28*0e209d39SAndroid Build Coastguard Worker     void addPropertyStarts(const USetAdder *sa, UErrorCode &errorCode) const;
29*0e209d39SAndroid Build Coastguard Worker     void addStrings(const USetAdder *sa, UProperty which, UErrorCode &errorCode) const;
30*0e209d39SAndroid Build Coastguard Worker 
31*0e209d39SAndroid Build Coastguard Worker     enum {
32*0e209d39SAndroid Build Coastguard Worker         // Byte offsets from the start of the data, after the generic header,
33*0e209d39SAndroid Build Coastguard Worker         // in ascending order.
34*0e209d39SAndroid Build Coastguard Worker         // UCPTrie=CodePointTrie, follows the indexes
35*0e209d39SAndroid Build Coastguard Worker         IX_CPTRIE_OFFSET,
36*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED1,
37*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED2,
38*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED3,
39*0e209d39SAndroid Build Coastguard Worker 
40*0e209d39SAndroid Build Coastguard Worker         // UCharsTrie=CharsTrie
41*0e209d39SAndroid Build Coastguard Worker         IX_BASIC_EMOJI_TRIE_OFFSET,
42*0e209d39SAndroid Build Coastguard Worker         IX_EMOJI_KEYCAP_SEQUENCE_TRIE_OFFSET,
43*0e209d39SAndroid Build Coastguard Worker         IX_RGI_EMOJI_MODIFIER_SEQUENCE_TRIE_OFFSET,
44*0e209d39SAndroid Build Coastguard Worker         IX_RGI_EMOJI_FLAG_SEQUENCE_TRIE_OFFSET,
45*0e209d39SAndroid Build Coastguard Worker         IX_RGI_EMOJI_TAG_SEQUENCE_TRIE_OFFSET,
46*0e209d39SAndroid Build Coastguard Worker         IX_RGI_EMOJI_ZWJ_SEQUENCE_TRIE_OFFSET,
47*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED10,
48*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED11,
49*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED12,
50*0e209d39SAndroid Build Coastguard Worker         IX_TOTAL_SIZE,
51*0e209d39SAndroid Build Coastguard Worker 
52*0e209d39SAndroid Build Coastguard Worker         // Not initially byte offsets.
53*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED14,
54*0e209d39SAndroid Build Coastguard Worker         IX_RESERVED15,
55*0e209d39SAndroid Build Coastguard Worker         IX_COUNT  // 16
56*0e209d39SAndroid Build Coastguard Worker     };
57*0e209d39SAndroid Build Coastguard Worker 
58*0e209d39SAndroid Build Coastguard Worker     // Properties in the code point trie.
59*0e209d39SAndroid Build Coastguard Worker     enum {
60*0e209d39SAndroid Build Coastguard Worker         // https://www.unicode.org/reports/tr51/#Emoji_Properties
61*0e209d39SAndroid Build Coastguard Worker         BIT_EMOJI,
62*0e209d39SAndroid Build Coastguard Worker         BIT_EMOJI_PRESENTATION,
63*0e209d39SAndroid Build Coastguard Worker         BIT_EMOJI_MODIFIER,
64*0e209d39SAndroid Build Coastguard Worker         BIT_EMOJI_MODIFIER_BASE,
65*0e209d39SAndroid Build Coastguard Worker         BIT_EMOJI_COMPONENT,
66*0e209d39SAndroid Build Coastguard Worker         BIT_EXTENDED_PICTOGRAPHIC,
67*0e209d39SAndroid Build Coastguard Worker         // https://www.unicode.org/reports/tr51/#Emoji_Sets
68*0e209d39SAndroid Build Coastguard Worker         BIT_BASIC_EMOJI
69*0e209d39SAndroid Build Coastguard Worker     };
70*0e209d39SAndroid Build Coastguard Worker 
71*0e209d39SAndroid Build Coastguard Worker private:
72*0e209d39SAndroid Build Coastguard Worker     static UBool U_CALLCONV
73*0e209d39SAndroid Build Coastguard Worker     isAcceptable(void *context, const char *type, const char *name, const UDataInfo *pInfo);
74*0e209d39SAndroid Build Coastguard Worker     /** Input i: One of the IX_..._TRIE_OFFSET indexes into the data file indexes[] array. */
getStringTrieIndex(int32_t i)75*0e209d39SAndroid Build Coastguard Worker     static int32_t getStringTrieIndex(int32_t i) {
76*0e209d39SAndroid Build Coastguard Worker         return i - IX_BASIC_EMOJI_TRIE_OFFSET;
77*0e209d39SAndroid Build Coastguard Worker     }
78*0e209d39SAndroid Build Coastguard Worker 
79*0e209d39SAndroid Build Coastguard Worker     void load(UErrorCode &errorCode);
80*0e209d39SAndroid Build Coastguard Worker     UBool hasBinaryPropertyImpl(UChar32 c, UProperty which) const;
81*0e209d39SAndroid Build Coastguard Worker     UBool hasBinaryPropertyImpl(const char16_t *s, int32_t length, UProperty which) const;
82*0e209d39SAndroid Build Coastguard Worker 
83*0e209d39SAndroid Build Coastguard Worker     UDataMemory *memory = nullptr;
84*0e209d39SAndroid Build Coastguard Worker     UCPTrie *cpTrie = nullptr;
85*0e209d39SAndroid Build Coastguard Worker     const char16_t *stringTries[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
86*0e209d39SAndroid Build Coastguard Worker };
87*0e209d39SAndroid Build Coastguard Worker 
88*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
89*0e209d39SAndroid Build Coastguard Worker 
90*0e209d39SAndroid Build Coastguard Worker #endif  // __EMOJIPROPS_H__
91