meanwhile  1.0.2
mw_util.h
Go to the documentation of this file.
1 
2 /*
3  Meanwhile - Unofficial Lotus Sametime Community Client Library
4  Copyright (C) 2004 Christopher (siege) O'Brien
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public
17  License along with this library; if not, write to the Free
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 
21 #ifndef _MW_UTIL_H
22 #define _MW_UTIL_H
23 
24 
25 #include <glib.h>
26 
27 
28 #define map_guint_new() \
29  g_hash_table_new(g_direct_hash, g_direct_equal)
30 
31 
32 #define map_guint_new_full(valfree) \
33  g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (valfree))
34 
35 
36 #define map_guint_insert(ht, key, val) \
37  g_hash_table_insert((ht), GUINT_TO_POINTER((guint)(key)), (val))
38 
39 
40 #define map_guint_replace(ht, key, val) \
41  g_hash_table_replace((ht), GUINT_TO_POINTER((guint)(key)), (val))
42 
43 
44 #define map_guint_lookup(ht, key) \
45  g_hash_table_lookup((ht), GUINT_TO_POINTER((guint)(key)))
46 
47 
48 #define map_guint_remove(ht, key) \
49  g_hash_table_remove((ht), GUINT_TO_POINTER((guint)(key)))
50 
51 
52 #define map_guint_steal(ht, key) \
53  g_hash_table_steal((ht), GUINT_TO_POINTER((guint)(key)))
54 
55 
56 GList *map_collect_keys(GHashTable *ht);
57 
58 
59 GList *map_collect_values(GHashTable *ht);
60 
61 
62 struct mw_datum {
63  gpointer data;
64  GDestroyNotify clear;
65 };
66 
67 
68 struct mw_datum *mw_datum_new(gpointer data, GDestroyNotify clear);
69 
70 
71 void mw_datum_set(struct mw_datum *d, gpointer data, GDestroyNotify clear);
72 
73 
74 gpointer mw_datum_get(struct mw_datum *d);
75 
76 
77 void mw_datum_clear(struct mw_datum *d);
78 
79 
80 void mw_datum_free(struct mw_datum *d);
81 
82 
83 #endif
gpointer mw_datum_get(struct mw_datum *d)
GDestroyNotify clear
Definition: mw_util.h:64
void mw_datum_set(struct mw_datum *d, gpointer data, GDestroyNotify clear)
void mw_datum_free(struct mw_datum *d)
GList * map_collect_keys(GHashTable *ht)
struct mw_datum * mw_datum_new(gpointer data, GDestroyNotify clear)
void mw_datum_clear(struct mw_datum *d)
GList * map_collect_values(GHashTable *ht)
gpointer data
Definition: mw_util.h:63
Definition: mw_util.h:62