1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = glib
28  * outFile = HashTableIter
29  * strct   = GHashTableIter
30  * realStrct=
31  * ctorStrct=
32  * clss    = HashTableIter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_hash_table_iter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.HashTable
47  * structWrap:
48  * 	- GHashTable* -> HashTable
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module glib.HashTableIter;
55 
56 public  import gtkc.glibtypes;
57 
58 private import gtkc.glib;
59 private import glib.ConstructionException;
60 
61 
62 private import glib.HashTable;
63 
64 
65 
66 
67 /**
68  * Description
69  * A GHashTable provides associations between keys and values which is
70  * optimized so that given a key, the associated value can be found
71  * very quickly.
72  * Note that neither keys nor values are copied when inserted into the
73  * GHashTable, so they must exist for the lifetime of the GHashTable.
74  * This means that the use of static strings is OK, but temporary
75  * strings (i.e. those created in buffers and those returned by GTK+
76  * widgets) should be copied with g_strdup() before being inserted.
77  * If keys or values are dynamically allocated, you must be careful to
78  * ensure that they are freed when they are removed from the
79  * GHashTable, and also when they are overwritten by new insertions
80  * into the GHashTable. It is also not advisable to mix static strings
81  * and dynamically-allocated strings in a GHashTable, because it then
82  * becomes difficult to determine whether the string should be freed.
83  * To create a GHashTable, use g_hash_table_new().
84  * To insert a key and value into a GHashTable, use
85  * g_hash_table_insert().
86  * To lookup a value corresponding to a given key, use
87  * g_hash_table_lookup() and g_hash_table_lookup_extended().
88  * To remove a key and value, use g_hash_table_remove().
89  * To call a function for each key and value pair use
90  * g_hash_table_foreach() or use a iterator to iterate over the
91  * key/value pairs in the hash table, see GHashTableIter.
92  * To destroy a GHashTable use g_hash_table_destroy().
93  */
94 public class HashTableIter
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GHashTableIter* gHashTableIter;
99 	
100 	
101 	public GHashTableIter* getHashTableIterStruct()
102 	{
103 		return gHashTableIter;
104 	}
105 	
106 	
107 	/** the main Gtk struct as a void* */
108 	protected void* getStruct()
109 	{
110 		return cast(void*)gHashTableIter;
111 	}
112 	
113 	/**
114 	 * Sets our main struct and passes it to the parent class
115 	 */
116 	public this (GHashTableIter* gHashTableIter)
117 	{
118 		this.gHashTableIter = gHashTableIter;
119 	}
120 	
121 	/**
122 	 */
123 	
124 	/**
125 	 * Initializes a key/value pair iterator and associates it with
126 	 * hash_table. Modifying the hash table after calling this function
127 	 * invalidates the returned iterator.
128 	 * $(DDOC_COMMENT example)
129 	 * Since 2.16
130 	 * Params:
131 	 * hashTable = a GHashTable.
132 	 */
133 	public void init(HashTable hashTable)
134 	{
135 		// void g_hash_table_iter_init (GHashTableIter *iter,  GHashTable *hash_table);
136 		g_hash_table_iter_init(gHashTableIter, (hashTable is null) ? null : hashTable.getHashTableStruct());
137 	}
138 	
139 	/**
140 	 * Advances iter and retrieves the key and/or value that are now
141 	 * pointed to as a result of this advancement. If FALSE is returned,
142 	 * key and value are not set, and the iterator becomes invalid.
143 	 * Since 2.16
144 	 * Params:
145 	 * key = a location to store the key, or NULL.
146 	 * value = a location to store the value, or NULL.
147 	 * Returns: FALSE if the end of the GHashTable has been reached.
148 	 */
149 	public int next(void** key, void** value)
150 	{
151 		// gboolean g_hash_table_iter_next (GHashTableIter *iter,  gpointer *key,  gpointer *value);
152 		return g_hash_table_iter_next(gHashTableIter, key, value);
153 	}
154 	
155 	/**
156 	 * Returns the GHashTable associated with iter.
157 	 * Since 2.16
158 	 * Returns: the GHashTable associated with iter.
159 	 */
160 	public HashTable getHashTable()
161 	{
162 		// GHashTable * g_hash_table_iter_get_hash_table (GHashTableIter *iter);
163 		auto p = g_hash_table_iter_get_hash_table(gHashTableIter);
164 		
165 		if(p is null)
166 		{
167 			return null;
168 		}
169 		
170 		return new HashTable(cast(GHashTable*) p);
171 	}
172 	
173 	/**
174 	 * Removes the key/value pair currently pointed to by the iterator
175 	 * from its associated GHashTable. Can only be called after
176 	 * g_hash_table_iter_next() returned TRUE, and cannot be called more
177 	 * than once for the same key/value pair.
178 	 * If the GHashTable was created using g_hash_table_new_full(), the
179 	 * key and value are freed using the supplied destroy functions, otherwise
180 	 * you have to make sure that any dynamically allocated values are freed
181 	 * yourself.
182 	 * Since 2.16
183 	 */
184 	public void remove()
185 	{
186 		// void g_hash_table_iter_remove (GHashTableIter *iter);
187 		g_hash_table_iter_remove(gHashTableIter);
188 	}
189 	
190 	/**
191 	 * Removes the key/value pair currently pointed to by the iterator
192 	 * from its associated GHashTable, without calling the key and value
193 	 * destroy functions. Can only be called after
194 	 * g_hash_table_iter_next() returned TRUE, and cannot be called more
195 	 * than once for the same key/value pair.
196 	 * Since 2.16
197 	 */
198 	public void steal()
199 	{
200 		// void g_hash_table_iter_steal (GHashTableIter *iter);
201 		g_hash_table_iter_steal(gHashTableIter);
202 	}
203 }