RE: Associating Strings and Variables
- From: "Ian Puleston" <ian underpressuredivers com>
- To: <bryan christ hp com>
- Cc: 'gtk-list' <gtk-list gnome org>
- Subject: RE: Associating Strings and Variables
- Date: Wed, 12 Apr 2006 14:30:20 -0700
You could do this quite easily by using a global GObject to hold your
associations. You can then use g_object_[sg]et_data to set/retrieve them,
e.g.:
/* At startup: */
gpointer assocObj = g_object_new(G_TYPE_OBJECT, NULL);
then:
g_object_set_data(assocObj, "some-name", some_data);
....
p = g_object_get_data(assocObj, "some-name");
Ian
> -----Original Message-----
> From: Christ, Bryan
> Sent: Wednesday, April 12, 2006 7:57 AM
>
> Thanks. I looked at Quarks and it seems they merely associated
> (psuedo-convert) strings to unique IDs which is not really what I want
> to achieve. I think that g_hash_* might work, but I was looking for
> something a little more opaque. In other words, I don't want to have to
> keep track of/pass the GHashTable* from/across functions. Perhaps I
> will just write a wrapper for that.
>
> On Wed, 2006-04-12 at 07:38 +0200, Diego Zuccato wrote:
> > Christ, Bryan wrote:
> > > I really hate to re-invent the wheel if someone has already done this.
> > > The idea here is that I can store a value in one function and recall
> it
> > > later from somewhere else just by a string reference.
> >
> > That's what hash tables are for... Look for g_hash_* .
> >
> > There should be something else, too (quarks?), but I don't remember
> > exactly, now.
> >
> > BYtE,
> > Diego.
> >
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]