summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-06-25 10:58:39 +0800
committerPeng Wu <alexepico@gmail.com>2012-06-25 11:10:36 +0800
commit61dff7403370bd1902c73c78be8312be4d3caa68 (patch)
tree55e8b3cc222def684bc68cbe56e7b7f938551a19
parentaa31075db890e53bc6cec08d99ba4fb250fcab12 (diff)
downloadlibpinyin-61dff7403370bd1902c73c78be8312be4d3caa68.tar.gz
libpinyin-61dff7403370bd1902c73c78be8312be4d3caa68.tar.xz
libpinyin-61dff7403370bd1902c73c78be8312be4d3caa68.zip
refactor pinyin_phrase_files
-rw-r--r--src/storage/phrase_index.cpp34
-rw-r--r--src/storage/phrase_index.h18
2 files changed, 37 insertions, 15 deletions
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