1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
/**
* Fonction permettant de creer un tableau dynamique
* @param iDataType le type des donnees qui suivent
* @param ... les données, pouvant etre des chaines, des booleens, des
* entiers, ou des GType. Il faut obligatoirement terminer par un
* G_TYPE_INVALID
* @return pointeur vers notre structure
*/
CidDataTable *
cid_create_datatable (GType iDataType, ...)
{
CidDataTable *res = cid_datatable_new();
GType iCurrType = iDataType;
va_list args;
va_start(args,iDataType);
void *current;
while ((current = va_arg(args,void *)) != G_TYPE_INVALID) {
CidDataContent *tmp = NULL;
if ((GType) current == G_TYPE_BOOLEAN || (GType) current == G_TYPE_INT || (GType) current == G_TYPE_STRING)
{
iCurrType = (GType) current;
continue;
}
switch (iCurrType)
{
case G_TYPE_BOOLEAN:
tmp = cid_datacontent_new_boolean(current);
break;
case G_TYPE_STRING:
tmp = cid_datacontent_new_string(current);
break;
case G_TYPE_INT:
tmp = cid_datacontent_new_int(current);
break;
default:
iCurrType = (GType) current;
}
res = cid_datatable_append(res,tmp);
}
va_end(args);
return res;
} |