mco_dict_struct_classcode

Return the descriptor for the structure/class referred to by its class code.

Prototype

    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
    );

Arguments

metadict
The address of an initialized mco_metadict_header_t structure.
dict_no
The index of the dictionary in the metadict->entries[] array (must be between 0 and mco_metadict_count() - 1).
class_code
The numeric class code assigned to the structure/class in the schema (must be in the range 1 to n_class_codes).
struct_info
Address of a mco_dict_struct_info_t variable to receive the structure/class descriptor.

Description

This function retrieves the descriptor for a structure or class identified by its numeric class_code within 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_code is within the valid range for the given dictionary and maps it to the corresponding structure descriptor.

Return Codes

MCO_S_OK
The structure/class descriptor was successfully returned.
MCO_E_UDA_DICT_NOTFOUND
The specified dictionary is not registered or invalid.
MCO_E_UDA_WRONG_CLASS_CODE
The provided class_code is out of range (less than 1 or greater than the number of classes in the dictionary).
MCO_E_ILLEGAL_PARAM
One or more input parameters are NULL.

Example

    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;
    }

Files

Header file:
mcouda.h
Source file:
mcouda.c
Library:
libmcouda.a