mco_dict_field_init_data

Return a pointer to the field's default data value.

Prototype

    MCO_RET mco_dict_field_init_data(
        /*IN*/ mco_metadict_header_t * metadict,
        /*IN*/ unsigned short dict_no,
        /*IN*/ unsigned short struct_no,
        /*IN*/ unsigned short field_no,
        /*OUT*/ mco_uda_value_t * buf
    );

Arguments

metadict
The address of an initialized mco_metadict_header_t structure.
dict_no
The number of the dictionary (must be between 0 and mco_metadict_count() - 1).
struct_no
The structure/class index (must be between 0 and mco_dict_struct_count() - 1).
field_no
The field number (must be between 0 and struct_info.field_count - 1).
buf
The address of a mco_uda_value_t variable to receive the field default data value.

Description

This function returns a pointer to the field's default data value by field_no.

Return Codes

MCO_S_OK
The field default data value was successfully returned.
MCO_E_UDA_DICT_NOTFOUND
The dictionary is not registered.
MCO_E_UDA_STRUCT_NOTFOUND
Invalid struct_no.
MCO_E_UDA_FIELD_NOTFOUND
Invalid field_no.

Example

    Application snippet:

    const char * dbname = "SimpleDb";

    int main(int argc, char* argv[])
    {
        MCO_RET rc;
        unsigned int dict_no = 0;
        unsigned int count;
        mco_metadict_header_t *header;
        const char * name = "MyClass";
        mco_dict_struct_info_t struct_info;
        mco_uda_value_t value;

        ...

        header = (mco_metadict_header_t *) malloc(size);
        mco_metadict_init(header, size); /* initialize the metadict */
        ...
        rc = mco_dict_struct_name(header, dict_no, name, &struct_info);
        for (i = 0; i < struct_info.field_count; ++i)
        {
            /* get field default value */
            value.type = MCO_DD_UINT4;
            rc = mco_dict_field_init_data(header, dict_no, struct_info.struct_no, i, &value);

            printf("Field %d : Default value %d\n", i, value.v.u4);
        }
        ...
    }

Files

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