From: Peng Huang Date: Tue, 13 Apr 2010 13:21:49 +0000 (+0800) Subject: Refactory PinyinParser X-Git-Tag: 1.3.10~232 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ccf66d9244a59e2830b71abe2d9b9ce007aff52a;p=platform%2Fupstream%2Fibus-libpinyin.git Refactory PinyinParser --- diff --git a/src/DoublePinyinEditor.cc b/src/DoublePinyinEditor.cc index 7280bb5..036b960 100644 --- a/src/DoublePinyinEditor.cc +++ b/src/DoublePinyinEditor.cc @@ -314,7 +314,7 @@ DoublePinyinEditor::isPinyin (gint i) return NULL; } - return m_parser.isPinyin (sheng, 0, PINYIN_INCOMPLETE_PINYIN); + return PinyinParser::isPinyin (sheng, 0, PINYIN_INCOMPLETE_PINYIN); } inline const Pinyin * @@ -330,10 +330,10 @@ DoublePinyinEditor::isPinyin (gint i, gint j) if (sheng == PINYIN_ID_ZERO && yun[0] == PINYIN_ID_ZERO) return pinyin; - pinyin = m_parser.isPinyin (sheng, yun[0], + pinyin = PinyinParser::isPinyin (sheng, yun[0], Config::option () & PINYIN_FUZZY_ALL); if (pinyin == NULL && yun[1] != PINYIN_ID_VOID) - pinyin = m_parser.isPinyin (sheng, yun[1], + pinyin = PinyinParser::isPinyin (sheng, yun[1], Config::option () & PINYIN_FUZZY_ALL); return pinyin; } diff --git a/src/DoublePinyinEditor.h b/src/DoublePinyinEditor.h index c3ce400..b73a229 100644 --- a/src/DoublePinyinEditor.h +++ b/src/DoublePinyinEditor.h @@ -29,8 +29,10 @@ public: void reset (void); void updateAuxiliaryTextAfter (String &buffer); -private: +protected: gboolean updatePinyin (gboolean all); + +private: const Pinyin *isPinyin (gint i, gint j); const Pinyin *isPinyin (gint i); diff --git a/src/FullPinyinEditor.cc b/src/FullPinyinEditor.cc index 432dc0b..74cb4c9 100644 --- a/src/FullPinyinEditor.cc +++ b/src/FullPinyinEditor.cc @@ -207,11 +207,11 @@ FullPinyinEditor::updatePinyin (void) m_pinyin_len = 0; } else { - m_pinyin_len = m_parser.parse (m_text, // text - m_cursor, // text length - Config::option (), // option - m_pinyin, // result - MAX_PHRASE_LEN); // max result length + m_pinyin_len = PinyinParser::parse (m_text, // text + m_cursor, // text length + Config::option (), // option + m_pinyin, // result + MAX_PHRASE_LEN); // max result length } updatePhraseEditor (); diff --git a/src/FullPinyinEditor.h b/src/FullPinyinEditor.h index 9e95fa8..22b6966 100644 --- a/src/FullPinyinEditor.h +++ b/src/FullPinyinEditor.h @@ -33,7 +33,6 @@ protected: gboolean moveCursorToBegin (void); gboolean moveCursorToEnd (void); -private: void updatePinyin (void); }; diff --git a/src/PinyinEditor.cc b/src/PinyinEditor.cc index e05110e..f018704 100644 --- a/src/PinyinEditor.cc +++ b/src/PinyinEditor.cc @@ -8,8 +8,6 @@ namespace PY { #define MAX_PINYIN_LEN 64 /* init static members */ -PinyinParser PinyinEditor::m_parser; - PinyinEditor::PinyinEditor (PinyinProperties & props) : Editor (props), m_pinyin (MAX_PHRASE_LEN), diff --git a/src/PinyinEditor.h b/src/PinyinEditor.h index d237fd6..76bfe12 100644 --- a/src/PinyinEditor.h +++ b/src/PinyinEditor.h @@ -105,9 +105,6 @@ protected: PhraseEditor m_phrase_editor; std::vector m_special_phrases; std::string m_selected_special_phrase; - -protected: - static PinyinParser m_parser; }; }; diff --git a/src/PinyinParser.h b/src/PinyinParser.h index c9ad552..e27f24b 100644 --- a/src/PinyinParser.h +++ b/src/PinyinParser.h @@ -9,18 +9,13 @@ namespace PY { class PinyinParser { - public: - PinyinParser (void) {} - ~PinyinParser (void) {} - - guint parse (const String &pinyin, // pinyin string - gint len, // length of pinyin string - guint option, // option - PinyinArray &result, // store pinyin in result - guint max); // max length of the result - const Pinyin * isPinyin (gint sheng, gint yun, guint option); + static guint parse (const String &pinyin, // pinyin string + gint len, // length of pinyin string + guint option, // option + PinyinArray &result, // store pinyin in result + guint max); // max length of the result + static const Pinyin * isPinyin (gint sheng, gint yun, guint option); }; - }; #endif