1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef HANGUL_P_H |
5 | #define HANGUL_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QString> |
19 | #include <QList> |
20 | #include <QMap> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | namespace QtVirtualKeyboard { |
24 | |
25 | class Hangul |
26 | { |
27 | Q_DISABLE_COPY(Hangul) |
28 | |
29 | enum HangulMedialIndex { // VIndex Letter Jungseong Double Jamo |
30 | // ---------------------------------------------------------------------- |
31 | HANGUL_MEDIAL_A, // 0 314F 1161 |
32 | HANGUL_MEDIAL_AE, // 1 3150 1162 |
33 | HANGUL_MEDIAL_YA, // 2 3151 1163 |
34 | HANGUL_MEDIAL_YAE, // 3 3152 1164 |
35 | HANGUL_MEDIAL_EO, // 4 3153 1165 |
36 | HANGUL_MEDIAL_E, // 5 3154 1166 |
37 | HANGUL_MEDIAL_YEO, // 6 3155 1167 |
38 | HANGUL_MEDIAL_YE, // 7 3156 1168 |
39 | HANGUL_MEDIAL_O, // 8 3157 1169 |
40 | HANGUL_MEDIAL_WA, // 9 3158 116A 3157+314F |
41 | HANGUL_MEDIAL_WAE, // 10 3159 116B 3157+3150 |
42 | HANGUL_MEDIAL_OE, // 11 315A 116C 3157+3163 |
43 | HANGUL_MEDIAL_YO, // 12 315B 116D |
44 | HANGUL_MEDIAL_U, // 13 315C 116E |
45 | HANGUL_MEDIAL_WEO, // 14 315D 116F 315C+3153 |
46 | HANGUL_MEDIAL_WE, // 15 315E 1170 315C+3154 |
47 | HANGUL_MEDIAL_WI, // 16 315F 1171 315C+3163 |
48 | HANGUL_MEDIAL_YU, // 17 3160 1172 |
49 | HANGUL_MEDIAL_EU, // 18 3161 1173 |
50 | HANGUL_MEDIAL_YI, // 19 3162 1174 3161+3163 |
51 | HANGUL_MEDIAL_I // 20 3163 1175 |
52 | }; |
53 | |
54 | enum HangulFinalIndex { // TIndex Letter Jongseong Double Jamo |
55 | // ---------------------------------------------------------------------- |
56 | HANGUL_FINAL_NONE, // 0 n/a n/a |
57 | HANGUL_FINAL_KIYEOK, // 1 3131 11A8 |
58 | HANGUL_FINAL_SSANGKIYEOK, // 2 3132 11A9 |
59 | HANGUL_FINAL_KIYEOK_SIOS, // 3 3133 11AA 3131+3145 |
60 | HANGUL_FINAL_NIEUN, // 4 3134 11AB |
61 | HANGUL_FINAL_NIEUN_CIEUC, // 5 3135 11AC 3134+3148 |
62 | HANGUL_FINAL_NIEUN_HIEUH, // 6 3136 11AD 3134+314E |
63 | HANGUL_FINAL_TIKEUT, // 7 3137 11AE |
64 | HANGUL_FINAL_RIEUL, // 8 3139 11AF |
65 | HANGUL_FINAL_RIEUL_KIYEOK, // 9 313A 11B0 3139+3131 |
66 | HANGUL_FINAL_RIEUL_MIEUM, // 10 313B 11B1 3139+3141 |
67 | HANGUL_FINAL_RIEUL_PIEUP, // 11 313C 11B2 3139+3142 |
68 | HANGUL_FINAL_RIEUL_SIOS, // 12 313D 11B3 3139+3145 |
69 | HANGUL_FINAL_RIEUL_THIEUTH, // 13 313E 11B4 3139+314C |
70 | HANGUL_FINAL_RIEUL_PHIEUPH, // 14 313F 11B5 3139+314D |
71 | HANGUL_FINAL_RIEUL_HIEUH, // 15 3140 11B6 3139+314E |
72 | HANGUL_FINAL_MIEUM, // 16 3141 11B7 |
73 | HANGUL_FINAL_PIEUP, // 17 3142 11B8 |
74 | HANGUL_FINAL_PIEUP_SIOS, // 18 3144 11B9 3142+3145 |
75 | HANGUL_FINAL_SIOS, // 19 3145 11BA |
76 | HANGUL_FINAL_SSANGSIOS, // 20 3146 11BB 3145+3145 |
77 | HANGUL_FINAL_IEUNG, // 21 3147 11BC |
78 | HANGUL_FINAL_CIEUC, // 22 3148 11BD |
79 | HANGUL_FINAL_CHIEUCH, // 23 314A 11BE |
80 | HANGUL_FINAL_KHIEUKH, // 24 314B 11BF |
81 | HANGUL_FINAL_THIEUTH, // 25 314C 11C0 |
82 | HANGUL_FINAL_PHIEUPH, // 26 314D 11C1 |
83 | HANGUL_FINAL_HIEUH // 27 314E 11C2 |
84 | }; |
85 | |
86 | Hangul(); |
87 | |
88 | public: |
89 | static QString decompose(const QString &source); |
90 | static QString compose(const QString &source); |
91 | static bool isJamo(const ushort &unicode); |
92 | |
93 | private: |
94 | static bool isMedial(HangulMedialIndex vowel); |
95 | static bool isFinal(HangulFinalIndex consonant); |
96 | static ushort findDoubleMedial(HangulMedialIndex vowel); |
97 | static ushort findDoubleFinal(HangulFinalIndex consonant); |
98 | static ushort packDoubleMedial(HangulMedialIndex a, HangulMedialIndex b); |
99 | static ushort packDoubleFinal(HangulFinalIndex a, HangulFinalIndex b); |
100 | static void unpackDoubleMedial(ushort key, HangulMedialIndex &a, HangulMedialIndex &b); |
101 | static void unpackDoubleFinal(ushort key, HangulFinalIndex &a, HangulFinalIndex &b); |
102 | static QMap<ushort, HangulMedialIndex> initDoubleMedialMap(); |
103 | static QMap<ushort, HangulFinalIndex> initDoubleFinalMap(); |
104 | |
105 | static const QList<ushort> initials; |
106 | static const QList<ushort> finals; |
107 | static const QMap<ushort, HangulMedialIndex> doubleMedialMap; |
108 | static const QMap<ushort, HangulFinalIndex> doubleFinalMap; |
109 | static const int SBase; |
110 | static const int LBase; |
111 | static const int VBase; |
112 | static const int TBase; |
113 | static const int LCount; |
114 | static const int VCount; |
115 | static const int TCount; |
116 | static const int NCount; |
117 | static const int SCount; |
118 | }; |
119 | |
120 | } // namespace QtVirtualKeyboard |
121 | QT_END_NAMESPACE |
122 | |
123 | #endif |
124 | |