Skip to content
parse-pinyin.cpp 660 B
Newer Older
#include "parse-pinyin.h"
Yuanle Song's avatar
Yuanle Song committed
#include "../PinyinArray.h"
#include "../PinyinParser.h"
#include "../Const.h"
Yuanle Song's avatar
Yuanle Song committed
GList *
parse_pinyin(const char *preedit_str, const guint max_pinyin, const guint flags)
Yuanle Song's avatar
Yuanle Song committed
	GList *result = NULL;
	PyZy::PinyinArray pyar = {0};
Yuanle Song's avatar
Yuanle Song committed
	Pinyin *thispy = NULL;

	PyZy::PinyinParser::parse(preedit_str, strlen(preedit_str), flags,
				  pyar, max_pinyin);
	for (guint i = 0; i < pyar.size(); ++i) {
Yuanle Song's avatar
Yuanle Song committed
		thispy = g_new(Pinyin, 1);
		thispy->shengmu_i = (int) pyar[i].pinyin->pinyin_id[0].sheng;
		thispy->yunmu_i = (int) pyar[i].pinyin->pinyin_id[0].yun;
		thispy->length = pyar[i].len;
Yuanle Song's avatar
Yuanle Song committed
		result = g_list_append(result, thispy);