Return the descriptor for the structure/class referred to by its class code.
MCO_RET mco_dict_struct_classcode(
/*IN*/ const mco_metadict_header_t *metadict,
/*IN*/ unsigned short dict_no,
/*IN*/ unsigned short class_code,
/*OUT*/ mco_dict_struct_info_p struct_info
);
metadict
mco_metadict_header_t structure.dict_no
metadict->entries[] array (must be between 0 and mco_metadict_count() - 1).class_code
1 to n_class_codes).struct_info
mco_dict_struct_info_t variable to receive the structure/class descriptor.This function retrieves the descriptor for a structure or class identified by its numeric
class_codewithin the specified dictionary (dict_no) of the metadata registry.Unlike
mco_dict_struct_name(), which looks up a class by its string name, this function uses the internal class code — a compact, integer-based identifier assigned at schema compilation time. This is useful for performance-critical or low-level operations where string comparison is undesirable.The function validates that the
class_codeis within the valid range for the given dictionary and maps it to the corresponding structure descriptor.
MCO_S_OK
MCO_E_UDA_WRONG_CLASS_CODE
class_code is out of range (less than 1 or greater than the number of classes in the dictionary).MCO_E_ILLEGAL_PARAM
NULL.
const char *dbname = "SimpleDb";
int main(int argc, char* argv[])
{
MCO_RET rc;
unsigned short dict_no = 0;
unsigned short class_code = 5; /* e.g., MyClass has class code 5 */
mco_metadict_header_t *header;
mco_dict_struct_info_t struct_info;
/* ... initialize metadict ... */
header = (mco_metadict_header_t *)malloc(size);
mco_metadict_init(header, size);
...
rc = mco_dict_struct_classcode(header, dict_no, class_code, &struct_info);
if (rc == MCO_S_OK) {
printf("Class name: %s\n", struct_info.name);
}
...
free(header);
return 0;
}