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 using namespace pinyin;
32 /** @file chewing_key.h
33 * @brief the definitions of chewing key related classes and structs.
37 /** Note: The parsed pinyins are stored in the following two
38 * GArrays to speed up chewing table lookup.
39 * As the chewing large table only contains information of struct ChewingKey.
44 guint16 m_initial : 5;
50 m_initial = CHEWING_ZERO_INITIAL;
51 m_middle = CHEWING_ZERO_MIDDLE;
52 m_final = CHEWING_ZERO_FINAL;
53 m_tone = CHEWING_ZERO_TONE;
56 _ChewingKey(ChewingInitial initial, ChewingMiddle middle,
61 m_tone = CHEWING_ZERO_TONE;
65 gint get_table_index();
67 /* Note: the return value should be freed by g_free. */
68 gchar * get_pinyin_string();
69 gchar * get_shengmu_string();
70 gchar * get_yunmu_string();
71 gchar * get_chewing_string();
74 typedef struct _ChewingKey ChewingKey;
76 static inline bool operator == (ChewingKey lhs, ChewingKey rhs) {
77 if (lhs.m_initial != rhs.m_initial)
79 if (lhs.m_middle != rhs.m_middle)
81 if (lhs.m_final != rhs.m_final)
83 if (lhs.m_tone != rhs.m_tone)
88 struct _ChewingKeyRest
90 /* Note: the table index is removed,
91 * Please use get_table_index in ChewingKey.
93 guint16 m_raw_begin; /* the begin of the raw input. */
94 guint16 m_raw_end; /* the end of the raw input. */
97 /* the 0th item in pinyin parser table is reserved for invalid. */
103 return m_raw_end - m_raw_begin;
107 typedef struct _ChewingKeyRest ChewingKeyRest;