summaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-03-21 09:49:21 +0800
committerPeng Wu <alexepico@gmail.com>2013-03-21 09:49:21 +0800
commit1ac46fc96bbdbd1c15d3fd5b3057ae606999d933 (patch)
tree8d5db82a16d431dc5aaf6bc6d2e537d85541989e /src/storage
parent04593227a1cd13020a00217e1dca1ded287cb8ed (diff)
downloadlibpinyin-1ac46fc96bbdbd1c15d3fd5b3057ae606999d933.tar.gz
libpinyin-1ac46fc96bbdbd1c15d3fd5b3057ae606999d933.tar.xz
libpinyin-1ac46fc96bbdbd1c15d3fd5b3057ae606999d933.zip
re-factor ChewingKey*
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/chewing_key.h14
-rw-r--r--src/storage/pinyin_parser2.cpp10
2 files changed, 14 insertions, 10 deletions
diff --git a/src/storage/chewing_key.h b/src/storage/chewing_key.h
index 7b25933..41b5664 100644
--- a/src/storage/chewing_key.h
+++ b/src/storage/chewing_key.h
@@ -37,21 +37,21 @@ namespace pinyin{
* As the chewing large table only contains information of struct ChewingKey.
*/
-struct ChewingKey
+struct _ChewingKey
{
guint16 m_initial : 5;
guint16 m_middle : 2;
guint16 m_final : 5;
guint16 m_tone : 3;
- ChewingKey() {
+ _ChewingKey() {
m_initial = CHEWING_ZERO_INITIAL;
m_middle = CHEWING_ZERO_MIDDLE;
m_final = CHEWING_ZERO_FINAL;
m_tone = CHEWING_ZERO_TONE;
}
- ChewingKey(ChewingInitial initial, ChewingMiddle middle,
+ _ChewingKey(ChewingInitial initial, ChewingMiddle middle,
ChewingFinal final) {
m_initial = initial;
m_middle = middle;
@@ -69,6 +69,8 @@ public:
gchar * get_chewing_string();
};
+typedef struct _ChewingKey ChewingKey;
+
static inline bool operator == (ChewingKey lhs, ChewingKey rhs) {
if (lhs.m_initial != rhs.m_initial)
return false;
@@ -81,7 +83,7 @@ static inline bool operator == (ChewingKey lhs, ChewingKey rhs) {
return true;
}
-struct ChewingKeyRest
+struct _ChewingKeyRest
{
/* Note: the table index is removed,
* Please use get_table_index in ChewingKey.
@@ -89,7 +91,7 @@ struct ChewingKeyRest
guint16 m_raw_begin; /* the begin of the raw input. */
guint16 m_raw_end; /* the end of the raw input. */
- ChewingKeyRest() {
+ _ChewingKeyRest() {
/* the 0th item in pinyin parser table is reserved for invalid. */
m_raw_begin = 0;
m_raw_end = 0;
@@ -100,6 +102,8 @@ struct ChewingKeyRest
}
};
+typedef struct _ChewingKeyRest ChewingKeyRest;
+
};
#endif
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index f4ea2dd..b8e603f 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -72,7 +72,7 @@ static bool check_chewing_options(pinyin_option_t options, const chewing_index_i
}
-gint ChewingKey::get_table_index() {
+gint _ChewingKey::get_table_index() {
assert(m_initial < CHEWING_NUMBER_OF_INITIALS);
assert(m_middle < CHEWING_NUMBER_OF_MIDDLES);
assert(m_final < CHEWING_NUMBER_OF_FINALS);
@@ -81,7 +81,7 @@ gint ChewingKey::get_table_index() {
return index == -1 ? 0 : index;
}
-gchar * ChewingKey::get_pinyin_string() {
+gchar * _ChewingKey::get_pinyin_string() {
assert(m_tone < CHEWING_NUMBER_OF_TONES);
gint index = get_table_index();
assert(index < G_N_ELEMENTS(content_table));
@@ -94,21 +94,21 @@ gchar * ChewingKey::get_pinyin_string() {
}
}
-gchar * ChewingKey::get_shengmu_string() {
+gchar * _ChewingKey::get_shengmu_string() {
gint index = get_table_index();
assert(index < G_N_ELEMENTS(content_table));
const content_table_item_t & item = content_table[index];
return g_strdup(item.m_shengmu_str);
}
-gchar * ChewingKey::get_yunmu_string() {
+gchar * _ChewingKey::get_yunmu_string() {
gint index = get_table_index();
assert(index < G_N_ELEMENTS(content_table));
const content_table_item_t & item = content_table[index];
return g_strdup(item.m_yunmu_str);
}
-gchar * ChewingKey::get_chewing_string() {
+gchar * _ChewingKey::get_chewing_string() {
assert(m_tone < CHEWING_NUMBER_OF_TONES);
gint index = get_table_index();
assert(index < G_N_ELEMENTS(content_table));