From 61dff7403370bd1902c73c78be8312be4d3caa68 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 25 Jun 2012 10:58:39 +0800 Subject: refactor pinyin_phrase_files --- src/storage/phrase_index.cpp | 34 ++++++++++++++++++++++------------ src/storage/phrase_index.h | 18 +++++++++++++++--- 2 files changed, 37 insertions(+), 15 deletions(-) (limited to 'src/storage') diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp index ad7c60c..8e73517 100644 --- a/src/storage/phrase_index.cpp +++ b/src/storage/phrase_index.cpp @@ -560,17 +560,27 @@ bool FacadePhraseIndex::compact(){ return true; } - -const char * pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT] = - { - NULL, - "gb_char.bin", - "gbk_char.bin" - }; - -const char * pinyin_table_files[PHRASE_INDEX_LIBRARY_COUNT] = +namespace pinyin{ +const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT] = { - NULL, - "gb_char.table", - "gbk_char.table" + {NULL, NULL, NULL, NOT_USED}, + {"gb_char.table", "gb_char.bin", "gb_char.dbin", SYSTEM_FILE}, + {"gbk_char.table", "gbk_char.bin", "gbk_char.dbin", SYSTEM_FILE}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + {NULL, NULL, NULL, NOT_USED}, + + {NULL, NULL, "user.bin", USER_FILE} }; +}; diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h index f1e460c..93704d6 100644 --- a/src/storage/phrase_index.h +++ b/src/storage/phrase_index.h @@ -727,10 +727,22 @@ public: return ERROR_OK; } }; + +typedef enum { + NOT_USED, /* not used. */ + SYSTEM_FILE, /* system phrase file. */ + USER_FILE, /* user only phrase file. */ +} PHRASE_FILE_TYPE; + +typedef struct { + const char * m_table_filename; + const char * m_system_filename; + const char * m_user_filename; + PHRASE_FILE_TYPE m_file_type; +} pinyin_table_info_t; + +extern const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT]; }; -extern const char * pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT]; -extern const char * pinyin_table_files[PHRASE_INDEX_LIBRARY_COUNT]; - #endif -- cgit