From d52ce00ad6718933db0df16451a8ea0a9e15e505 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Thu, 20 May 2010 11:07:30 +0800 Subject: [PATCH] Adjust Phrase struct --- src/Database.cc | 14 +++++++------- src/Phrase.h | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Database.cc b/src/Database.cc index 3467072..1ca23b4 100644 --- a/src/Database.cc +++ b/src/Database.cc @@ -149,8 +149,8 @@ Query::fill (PhraseArray &phrases, gint count) phrase.len = m_pinyin_len; for (guint i = 0, column = DB_COLUMN_S0; i < m_pinyin_len; i++) { - phrase.pinyin_id[i][0] = m_stmt->columnInt (column++); - phrase.pinyin_id[i][1] = m_stmt->columnInt (column++); + phrase.pinyin_id[i].sheng = m_stmt->columnInt (column++); + phrase.pinyin_id[i].yun = m_stmt->columnInt (column++); } phrases.push_back (phrase); @@ -537,11 +537,11 @@ inline void Database::phraseWhereSql (const Phrase & p, String & sql) { sql << " WHERE"; - sql << " s0=" << p.pinyin_id[0][0] - << " AND y0=" << p.pinyin_id[0][1]; + sql << " s0=" << p.pinyin_id[0].sheng + << " AND y0=" << p.pinyin_id[0].yun; for (guint i = 1; i < p.len; i++) { - sql << " AND s" << i << '=' << p.pinyin_id[i][0] - << " AND y" << i << '=' << p.pinyin_id[i][1]; + sql << " AND s" << i << '=' << p.pinyin_id[i].sheng + << " AND y" << i << '=' << p.pinyin_id[i].yun; } sql << " AND phrase=\"" << p.phrase << "\""; @@ -556,7 +556,7 @@ Database::phraseSql (const Phrase & p, String & sql) << ',' << p.freq; /* freq */ for (guint i = 0; i < p.len; i++) { - sql << ',' << p.pinyin_id[i][0] << ',' << p.pinyin_id[i][1]; + sql << ',' << p.pinyin_id[i].sheng << ',' << p.pinyin_id[i].yun; } sql << ");\n"; diff --git a/src/Phrase.h b/src/Phrase.h index 819b17a..0534b11 100644 --- a/src/Phrase.h +++ b/src/Phrase.h @@ -13,7 +13,10 @@ struct Phrase { gchar phrase[PHRASE_LEN_IN_BYTE]; guint freq; guint user_freq; - guint8 pinyin_id[MAX_PHRASE_LEN][2]; + struct { + guint8 sheng; + guint8 yun; + } pinyin_id[MAX_PHRASE_LEN]; guint len; void reset (void) { -- 2.7.4