Re: Conversion between glib data structures



Morten Welinder <terra diku dk> writes:
> While Gnumeric-hacking, I quite often find it necessary to convert
> from one glib data structure to another.  Glib has no provisions
> for that, it seems.
> 
> Typically, things have been built and maintained as a hash for
> speed, but is needed as a list in the end.  This can certainly
> be done with the current method of _foreach, but it's cumbersome
> and quite inelegant in C.
> 
> Would it be acceptable to add a bunch of functions to glib?
> Specifically...
> 
> GSList *g_hash_table_to_slist (GHash *h, gboolean keys, gboolean values);
> GList *g_hash_table_to_list (GHash *h, gboolean keys, gboolean values);
> GPtrArray *g_hash_table_to_ptrarray (GHash *h, gboolean keys, gboolean values);
> 
> And possibly, for naming convenience:
> 
> #define g_hash_table_domain_slist(h) \
>   g_hash_table_to_slist (h, TRUE, FALSE)
> #define g_hash_table_range_slist(h) \
>   g_hash_table_to_slist (h, FALSE, TRUE)
> 
> etc.
> 
> These should probably be placed in a file of their own, to avoid tying
> the .o files together with inter-file references.
> 
> Comments?
> 

I think we've discussed this before, I don't remember if we reached a
conclusion. In any case it's definitely a 2.2 issue at this point -
I'd suggest filing an API bug report (with "API" keyword) and we'll
put it on the future milestone to think about for 2.2.

Havoc





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]