source: appstream-generator/build/girepo/glib/HashTableIter.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.8 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.HashTableIter;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.HashTable;
26
27
28/**
29 * A GHashTableIter structure represents an iterator that can be used
30 * to iterate over the elements of a #GHashTable. GHashTableIter
31 * structures are typically allocated on the stack and then initialized
32 * with g_hash_table_iter_init().
33 */
34public class HashTableIter
35{
36        /** the main Gtk struct */
37        protected GHashTableIter* gHashTableIter;
38        protected bool ownedRef;
39
40        /** Get the main Gtk struct */
41        public GHashTableIter* getHashTableIterStruct()
42        {
43                return gHashTableIter;
44        }
45
46        /** the main Gtk struct as a void* */
47        protected void* getStruct()
48        {
49                return cast(void*)gHashTableIter;
50        }
51
52        /**
53         * Sets our main struct and passes it to the parent class.
54         */
55        public this (GHashTableIter* gHashTableIter, bool ownedRef = false)
56        {
57                this.gHashTableIter = gHashTableIter;
58                this.ownedRef = ownedRef;
59        }
60
61
62        /**
63         * Returns the #GHashTable associated with @iter.
64         *
65         * Returns: the #GHashTable associated with @iter.
66         *
67         * Since: 2.16
68         */
69        public HashTable getHashTable()
70        {
71                auto p = g_hash_table_iter_get_hash_table(gHashTableIter);
72               
73                if(p is null)
74                {
75                        return null;
76                }
77               
78                return new HashTable(cast(GHashTable*) p);
79        }
80
81        /**
82         * Initializes a key/value pair iterator and associates it with
83         * @hash_table. Modifying the hash table after calling this function
84         * invalidates the returned iterator.
85         * |[<!-- language="C" -->
86         * GHashTableIter iter;
87         * gpointer key, value;
88         *
89         * g_hash_table_iter_init (&iter, hash_table);
90         * while (g_hash_table_iter_next (&iter, &key, &value))
91         * {
92         * // do something with key and value
93         * }
94         * ]|
95         *
96         * Params:
97         *     hashTable = a #GHashTable
98         *
99         * Since: 2.16
100         */
101        public void init(HashTable hashTable)
102        {
103                g_hash_table_iter_init(gHashTableIter, (hashTable is null) ? null : hashTable.getHashTableStruct());
104        }
105
106        /**
107         * Advances @iter and retrieves the key and/or value that are now
108         * pointed to as a result of this advancement. If %FALSE is returned,
109         * @key and @value are not set, and the iterator becomes invalid.
110         *
111         * Params:
112         *     key = a location to store the key, or %NULL
113         *     value = a location to store the value, or %NULL
114         *
115         * Returns: %FALSE if the end of the #GHashTable has been reached.
116         *
117         * Since: 2.16
118         */
119        public bool next(void** key, void** value)
120        {
121                return g_hash_table_iter_next(gHashTableIter, key, value) != 0;
122        }
123
124        /**
125         * Removes the key/value pair currently pointed to by the iterator
126         * from its associated #GHashTable. Can only be called after
127         * g_hash_table_iter_next() returned %TRUE, and cannot be called
128         * more than once for the same key/value pair.
129         *
130         * If the #GHashTable was created using g_hash_table_new_full(),
131         * the key and value are freed using the supplied destroy functions,
132         * otherwise you have to make sure that any dynamically allocated
133         * values are freed yourself.
134         *
135         * It is safe to continue iterating the #GHashTable afterward:
136         * |[<!-- language="C" -->
137         * while (g_hash_table_iter_next (&iter, &key, &value))
138         * {
139         * if (condition)
140         * g_hash_table_iter_remove (&iter);
141         * }
142         * ]|
143         *
144         * Since: 2.16
145         */
146        public void remove()
147        {
148                g_hash_table_iter_remove(gHashTableIter);
149        }
150
151        /**
152         * Replaces the value currently pointed to by the iterator
153         * from its associated #GHashTable. Can only be called after
154         * g_hash_table_iter_next() returned %TRUE.
155         *
156         * If you supplied a @value_destroy_func when creating the
157         * #GHashTable, the old value is freed using that function.
158         *
159         * Params:
160         *     value = the value to replace with
161         *
162         * Since: 2.30
163         */
164        public void replace(void* value)
165        {
166                g_hash_table_iter_replace(gHashTableIter, value);
167        }
168
169        /**
170         * Removes the key/value pair currently pointed to by the
171         * iterator from its associated #GHashTable, without calling
172         * the key and value destroy functions. Can only be called
173         * after g_hash_table_iter_next() returned %TRUE, and cannot
174         * be called more than once for the same key/value pair.
175         *
176         * Since: 2.16
177         */
178        public void steal()
179        {
180                g_hash_table_iter_steal(gHashTableIter);
181        }
182}
Note: See TracBrowser for help on using the repository browser.