summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-11-12 13:27:12 +0800
committerPeng Wu <alexepico@gmail.com>2012-11-12 13:27:12 +0800
commit0555fdd296f422c202098d42486c83f4a576dd93 (patch)
tree9568d06aabb295454bbdfa2455871100807d79bd /src
parent5ac93b27a0b3fe0c23de226ba255643cfe93d40e (diff)
downloadlibpinyin-0555fdd296f422c202098d42486c83f4a576dd93.tar.gz
libpinyin-0555fdd296f422c202098d42486c83f4a576dd93.tar.xz
libpinyin-0555fdd296f422c202098d42486c83f4a576dd93.zip
write mask out for facade tables
Diffstat (limited to 'src')
-rw-r--r--src/include/novel_types.h3
-rw-r--r--src/storage/facade_chewing_table.h19
-rw-r--r--src/storage/facade_phrase_table2.h23
3 files changed, 40 insertions, 5 deletions
diff --git a/src/include/novel_types.h b/src/include/novel_types.h
index e2d2363..52fc0b0 100644
--- a/src/include/novel_types.h
+++ b/src/include/novel_types.h
@@ -86,7 +86,8 @@ enum ErrorResult{
ERROR_OUT_OF_RANGE, /* beyond the end of the sub phrase index */
ERROR_FILE_CORRUPTION, /* file is corrupted */
ERROR_INTEGER_OVERFLOW, /* integer is overflowed */
- ERROR_ALREADY_EXISTS /* the sub phrase already exists. */
+ ERROR_ALREADY_EXISTS, /* the sub phrase already exists. */
+ ERROR_NO_USER_TABLE /* the user table is not loaded. */
};
/* For N-gram */
diff --git a/src/storage/facade_chewing_table.h b/src/storage/facade_chewing_table.h
index 50683eb..572ce04 100644
--- a/src/storage/facade_chewing_table.h
+++ b/src/storage/facade_chewing_table.h
@@ -174,7 +174,7 @@ public:
int add_index(int phrase_length, /* in */ ChewingKey keys[],
/* in */ phrase_token_t token) {
if (NULL == m_user_chewing_table)
- return false;
+ return ERROR_NO_USER_TABLE;
return m_user_chewing_table->add_index(phrase_length, keys, token);
}
@@ -191,9 +191,24 @@ public:
int remove_index(int phrase_length, /* in */ ChewingKey keys[],
/* in */ phrase_token_t token) {
if (NULL == m_user_chewing_table)
- return false;
+ return ERROR_NO_USER_TABLE;
return m_user_chewing_table->remove_index(phrase_length, keys, token);
}
+
+ /**
+ * FacadeChewingTable::mask_out:
+ * @mask: the mask.
+ * @value: the value.
+ * @returns: whether the mask out operation is successful.
+ *
+ * Mask out the matched chewing index.
+ *
+ */
+ bool mask_out(phrase_token_t mask, phrase_token_t value) {
+ if (NULL == m_user_chewing_table)
+ return false;
+ return m_user_chewing_table->mask_out(mask, value);
+ }
};
};
diff --git a/src/storage/facade_phrase_table2.h b/src/storage/facade_phrase_table2.h
index b9bc9ca..4167ada 100644
--- a/src/storage/facade_phrase_table2.h
+++ b/src/storage/facade_phrase_table2.h
@@ -154,7 +154,8 @@ public:
int add_index(int phrase_length, /* in */ ucs4_t phrase[],
/* in */ phrase_token_t token) {
if (NULL == m_user_phrase_table)
- return false;
+ return ERROR_NO_USER_TABLE;
+
return m_user_phrase_table->add_index
(phrase_length, phrase, token);
}
@@ -172,10 +173,28 @@ public:
int remove_index(int phrase_length, /* in */ ucs4_t phrase[],
/* in */ phrase_token_t token) {
if (NULL == m_user_phrase_table)
- return false;
+ return ERROR_NO_USER_TABLE;
+
return m_user_phrase_table->remove_index
(phrase_length, phrase, token);
}
+
+ /**
+ * FacadePhraseTable2::mask_out:
+ * @mask: the mask.
+ * @value: the value.
+ * @returns: whether the mask out operation is successful.
+ *
+ * Mask out the matched phrase index.
+ *
+ */
+ bool mask_out(phrase_token_t mask, phrase_token_t value) {
+ if (NULL == m_user_phrase_table)
+ return false;
+
+ return m_user_phrase_table->mask_out
+ (mask, value);
+ }
};
};