summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-10-19 12:18:04 +0800
committerPeng Wu <alexepico@gmail.com>2012-10-19 12:18:04 +0800
commit484cf316c1257bf138815614c1576d4fcbbeac6c (patch)
tree2fc76708752cf8410f5fed149442c8f3226d921d /utils
parentf7bfa0e630aaf59c40cfa2fbed64a986b18505df (diff)
downloadlibpinyin-484cf316c1257bf138815614c1576d4fcbbeac6c.tar.gz
libpinyin-484cf316c1257bf138815614c1576d4fcbbeac6c.tar.xz
libpinyin-484cf316c1257bf138815614c1576d4fcbbeac6c.zip
update utils helper
Diffstat (limited to 'utils')
-rw-r--r--utils/utils_helper.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/utils_helper.h b/utils/utils_helper.h
index bada86b..520c14f 100644
--- a/utils/utils_helper.h
+++ b/utils/utils_helper.h
@@ -48,6 +48,23 @@
var = conv((const char *)value); \
}
+#define TAGLIB_PARSE_SEGMENTED_LINE(phrase_index, var, line) \
+ phrase_token_t var = null_token; \
+ { \
+ gchar ** strs = g_strsplit_set(line, " \t", 2); \
+ assert(2 == g_strv_length(strs)); \
+ \
+ phrase_token_t token = atoi(strs[0]); \
+ const char * phrase = strs[1]; \
+ if (null_token != token) \
+ assert(taglib_validate_token_with_string \
+ (phrase_index, token, phrase)); \
+ \
+ var = token; \
+ \
+ g_strfreev(strs); \
+ }
+
static bool load_phrase_index(FacadePhraseIndex * phrase_index) {
MemoryChunk * chunk = NULL;