compare function for GValues
- From: Stefan Kost <kost imn htwk-leipzig de>
- To: gtk-app-devel-list gnome org
- Subject: compare function for GValues
- Date: Thu, 28 Oct 2004 11:47:30 +0200
hi hi,
we have lots of methods in our project the looksup list-entries by a gobject
property (the lists node->data entries are gobject instances).
We would like to generalize the code - something like below:
-- pseudo code --
find_by_property(gpointer item,gpointer data) {
GValue value;
g_object_get_property(item,data.key,&value);
//a) compare via
strcmp(find_by_property(value),find_by_property(data.compare_value));
//b) switch(g_value_get_type(value)) {
// G_TYPE_STRING: strcmp(value,data.compare_value);
// default: value==data.compare_value;
// }
}
struct {
gchar *key;
GValue compare_value;
} data;
g_value_init(data.compare_value, G_TYPE_STRING);
g_value_set_string(data.compare_value,id);
data.key="id";
node = g_list_find_custom(self->priv->machines, data, find_by_property);
if(node) return(BT_MACHINE(node->data);
-- pseudo code --
Any ideas how to best handle the missing copare function in the GValue system?
Stefan
--
\|/ Stefan Kost
<@ @> private business
+-oOO-(_)-OOo------------------------------------------------------ - - - - -
| __ Address Simildenstr. 5 HTWK Leipzig, Fb IMN, Postfach 301166
| /// 04277 Leipzig 04251 Leipzig
| __ /// Germany Germany
| \\\/// Phone +49341 2253538 +49341 30766101
| \__/ EMail st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
| WWW www.sonicpulse.de www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - - - -
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]