summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-09-17 11:00:49 +0800
committerPeng Wu <alexepico@gmail.com>2013-09-17 11:00:49 +0800
commit4aea76388dd426abf5d4d190e8c73caa2bce0182 (patch)
treeee71a5584e01ba5270c99c0e981664344bb304dd
parent532bda01b0b9072036ab531f94c2ced6f9226955 (diff)
downloadlibzhuyin-4aea76388dd426abf5d4d190e8c73caa2bce0182.tar.gz
libzhuyin-4aea76388dd426abf5d4d190e8c73caa2bce0182.tar.xz
libzhuyin-4aea76388dd426abf5d4d190e8c73caa2bce0182.zip
improves set_scheme method
-rw-r--r--src/storage/pinyin_parser2.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index 7b0bf9a..51b42db 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -728,38 +728,36 @@ int ChewingDiscreteParser2::parse(pinyin_option_t options,
}
bool ChewingDiscreteParser2::set_scheme(ChewingScheme scheme) {
+ m_options = 0;
+
+#define INIT_PARSER(index, table) { \
+ m_chewing_index = index; \
+ m_chewing_index_len = G_N_ELEMENTS(index); \
+ m_initial_table = chewing_##table##_initials; \
+ m_middle_table = chewing_##table##_middles; \
+ m_final_table = chewing_##table##_finals; \
+ m_tone_table = chewing_##table##_tones; \
+ }
+
switch(scheme) {
case CHEWING_HSU:
m_options = HSU_CORRECT;
- m_chewing_index = hsu_bopomofo_index;
- m_chewing_index_len = G_N_ELEMENTS(hsu_bopomofo_index);
- m_initial_table = chewing_hsu_initials;
- m_middle_table = chewing_hsu_middles;
- m_final_table = chewing_hsu_finals;
- m_tone_table = chewing_hsu_tones;
+ INIT_PARSER(hsu_bopomofo_index, hsu);
break;
case CHEWING_HSU_DVORAK:
m_options = HSU_CORRECT;
- m_chewing_index = hsu_bopomofo_index;
- m_chewing_index_len = G_N_ELEMENTS(hsu_bopomofo_index);
- m_initial_table = chewing_hsu_dvorak_initials;
- m_middle_table = chewing_hsu_dvorak_middles;
- m_final_table = chewing_hsu_dvorak_finals;
- m_tone_table = chewing_hsu_dvorak_tones;
+ INIT_PARSER(hsu_bopomofo_index, hsu_dvorak);
break;
case CHEWING_ETEN26:
m_options = ETEN26_CORRECT;
- m_chewing_index = eten26_bopomofo_index;
- m_chewing_index_len = G_N_ELEMENTS(eten26_bopomofo_index);
- m_initial_table = chewing_eten26_initials;
- m_middle_table = chewing_eten26_middles;
- m_final_table = chewing_eten26_finals;
- m_tone_table = chewing_eten26_tones;
+ INIT_PARSER(eten26_bopomofo_index, eten26)
break;
default:
assert(FALSE);
}
+#undef INIT_PARSER
+
return false;
}