3 * Library to deal with pinyin.
5 * Copyright (C) 2011 Peng Wu <alexepico@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "chewing_enum.h"
28 /** @file chewing_key.h
29 * @brief the definitions of chewing key related classes and structs.
36 * @brief enums of Double Pinyin Schemes.
38 enum DoublePinyinScheme
40 DOUBLE_PINYIN_ZRM = 1,
42 DOUBLE_PINYIN_ZIGUANG = 3,
43 DOUBLE_PINYIN_ABC = 4,
44 DOUBLE_PINYIN_PYJJ = 6,
45 DOUBLE_PINYIN_XHE = 7,
46 DOUBLE_PINYIN_CUSTOMIZED = 30, /* for user's keyboard */
47 DOUBLE_PINYIN_DEFAULT = DOUBLE_PINYIN_MS
51 * @brief enums of Chewing Schemes.
59 CHEWING_DEFAULT = CHEWING_STANDARD
63 /** Note: The parsed pinyins are stored in the following two
64 * GArrays to speed up chewing table lookup.
65 * As the chewing large table only contains information of struct ChewingKey.
70 guint16 m_initial : 5;
76 m_initial = CHEWING_ZERO_INITIAL;
77 m_middle = CHEWING_ZERO_MIDDLE;
78 m_final = CHEWING_ZERO_FINAL;
79 m_tone = CHEWING_ZERO_TONE;
82 ChewingKey(ChewingInitial initial, ChewingMiddle middle,
87 m_tone = CHEWING_ZERO_TONE;
91 gint get_table_index();
93 /* Note: the return value should be freed by g_free. */
94 gchar * get_pinyin_string();
95 gchar * get_chewing_string();
98 static inline bool operator == (ChewingKey lhs, ChewingKey rhs) {
99 if (lhs.m_initial != rhs.m_initial)
101 if (lhs.m_middle != rhs.m_middle)
103 if (lhs.m_final != rhs.m_final)
105 if (lhs.m_tone != rhs.m_tone)
110 struct ChewingKeyRest
112 /* Note: the table index is removed,
113 * Please use get_table_index in ChewingKey.
115 guint16 m_raw_begin; /* the begin of the raw input. */
116 guint16 m_raw_end; /* the end of the raw input. */
119 /* the 0th item in pinyin parser table is reserved for invalid. */
125 return m_raw_end - m_raw_begin;