mco_metadict_count MCO_RET mco_metadict_count( /*IN*/ mco_metadict_header_t * metadict,
/*OUT*/ unsigned short * count );
此函数返回已注册数据库的数量 (metadict->n_allocated )。(请注意,由于可以取消注册 字典,因此在调用 function 时必须考虑到这一点。如果使用了字典注销操作,则必须检查 function 返回的值,该值指示是否实际存在具有指定编号的字典。请参阅下面的示例。mco_metadict_count()``mco_metadict_entry()
MCO_S_OK 已成功返回计数 MCO_E_UDA_NAME_TOO_LONG 词典名称太长
/* 应用程序代码片段 */
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
MCO_RET rc;
unsigned int total_count, registered_count;
mco_metadict_header_t *header;
unsigned short dict_no;
mco_metadict_size(1, &size);
header = (mco_metadict_header_t *) malloc(size);
mco_metadict_init(header, size); /* initialize the metadict */
...
/* Get total number of registered dictionaries and subtract unregistered entries */
mco_metadict_count(metadict, &total_count);
for (dict_no=0, registered_count=0; dict_no < total_count; ++dict_no)
{
MCO_RET rc;
mco_metadict_entry_t *entry;
/* Get dictionary by number and check if it is registered */
rc = mco_metadict_entry(metadict, dict_no, &entry);
if (rc == MCO_E_UDA_DICT_NOTFOUND) continue;
registered_count++;
}
...
}
上一页
mco_metadict_register
下一页
mco_metadict_entry