You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
67 lines
1.7 KiB
#include "connor_util.h"
|
|
|
|
/**
|
|
*判断某个对象是否是类或者子类
|
|
*objtag 要判断的对象
|
|
*type_name 类型的名称
|
|
*/
|
|
int checkIsTypeOrSubtype(tag_t objtag,char * type_name){
|
|
printf("判断是否是%s及其子类\n",type_name);
|
|
tag_t type = NULLTAG;
|
|
ITKCALL(TCTYPE_ask_object_type(objtag,&type));
|
|
tag_t item_type = NULLTAG;
|
|
ITKCALL(TCTYPE_find_type(type_name,"",&item_type));
|
|
int is_type = 0;
|
|
if(item_type != NULLTAG){
|
|
printf("找到%s类\n",type_name);
|
|
//printf(" find Folder type ok !!!! \n");
|
|
logical isok = FALSE;
|
|
ITKCALL(TCTYPE_is_type_of(type,item_type,&isok));
|
|
if(isok){
|
|
printf("是%s类及其子类\n\n",type_name);
|
|
is_type= 1;
|
|
}else{
|
|
printf("不是%s类及其子类\n\n",type_name);
|
|
is_type= 0;
|
|
}
|
|
}else{
|
|
printf("没有找到%s类\n\n",type_name);
|
|
}
|
|
return is_type;
|
|
}
|
|
|
|
/**
|
|
* 获取首选项
|
|
*/
|
|
int getPrefStrings( const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec )
|
|
{
|
|
int ifail = ITK_ok , i = 0, j = 0, k =0, num = 0;
|
|
char **values;
|
|
TC_preference_search_scope_t old_scope;
|
|
// ITKCALL( ifail = PREF_ask_search_scope( &old_scope) );
|
|
//ITKCALL( ifail = PREF_set_search_scope( scope ) );
|
|
ITKCALL( ifail = PREF_ask_char_values( preference, &num, &values ) );
|
|
//WriteLog("num=%d",num);
|
|
for(i = 0; i < num; i++)
|
|
{
|
|
pref_vec.push_back(values[i]);
|
|
}
|
|
DOFREE(values);
|
|
// ITKCALL( ifail = PREF_set_search_scope( old_scope ) );
|
|
return ifail;
|
|
}
|
|
|
|
void split(std::string s, const char* delim, std::vector<std::string>* ret)
|
|
{
|
|
size_t last = 0;
|
|
size_t index = s.find(delim, last);
|
|
int size = strlen(delim);
|
|
while (index != std::string::npos) {
|
|
ret->push_back(s.substr(last, index - last));
|
|
last = index + size;
|
|
index = s.find(delim, last);
|
|
}
|
|
if (index - last > 0) {
|
|
ret->push_back(s.substr(last, index - last));
|
|
}
|
|
} |