Return the number of registered databases.
MCO_RET mco_metadict_count( /*IN*/ mco_metadict_header_t * metadict,
/*OUT*/ unsigned short * count );
| metadict | The address of a mco_metadict_header_t structure to initialize |
|
count |
The address of a variable to receive the number of databases |
This function returns the number of registered databases (metadict->n_allocated). (Note that, as it is possible to unregister a dictionary, this must be taken into account when calling function
mco_metadict_count(). If dictionary unregister operations were used then it is necessary to check the value returned by functionmco_metadict_entry()which indicates whether a dictionary with specified number actually exists. See example below.)
| MCO_S_OK | The count was successfully returned |
|
The dictionary name is too long |
Application snippet:
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++;
}
...
}