Coverage Report

Created: 2025-06-13 06:34

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