root/trunk/src/gio/UnixFDList.d

Revision 938, 8.2 kB (checked in by Mike Wey, 3 months ago)

Update Gio to 2.28.

Line 
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  = GUnixFDList.html
27  * outPack = gio
28  * outFile = UnixFDList
29  * strct   = GUnixFDList
30  * realStrct=
31  * ctorStrct=
32  * clss    = UnixFDList
33  * interf  =
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  =
38  * implements:
39  * prefixes:
40  *  - g_unix_fd_list_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  *  - glib.ErrorG
47  *  - glib.GException
48  * structWrap:
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53
54 module gio.UnixFDList;
55
56 public  import gtkc.giotypes;
57
58 private import gtkc.gio;
59 private import glib.ConstructionException;
60
61
62 private import glib.ErrorG;
63 private import glib.GException;
64
65
66
67 private import gobject.ObjectG;
68
69 /**
70  * Description
71  * A GUnixFDList contains a list of file descriptors. It owns the file
72  * descriptors that it contains, closing them when finalized.
73  * It may be wrapped in a GUnixFDMessage and sent over a GSocket in
74  * the G_SOCKET_ADDRESS_UNIX family by using g_socket_send_message()
75  * and received using g_socket_receive_message().
76  * Note that <gio/gunixfdlist.h> belongs to
77  * the UNIX-specific GIO interfaces, thus you have to use the
78  * gio-unix-2.0.pc pkg-config file when using it.
79  */
80 public class UnixFDList : ObjectG
81 {
82    
83     /** the main Gtk struct */
84     protected GUnixFDList* gUnixFDList;
85    
86    
87     public GUnixFDList* getUnixFDListStruct()
88     {
89         return gUnixFDList;
90     }
91    
92    
93     /** the main Gtk struct as a void* */
94     protected override void* getStruct()
95     {
96         return cast(void*)gUnixFDList;
97     }
98    
99     /**
100      * Sets our main struct and passes it to the parent class
101      */
102     public this (GUnixFDList* gUnixFDList)
103     {
104         if(gUnixFDList is null)
105         {
106             this = null;
107             return;
108         }
109         //Check if there already is a D object for this gtk struct
110         void* ptr = getDObject(cast(GObject*)gUnixFDList);
111         if( ptr !is null )
112         {
113             this = cast(UnixFDList)ptr;
114             return;
115         }
116         super(cast(GObject*)gUnixFDList);
117         this.gUnixFDList = gUnixFDList;
118     }
119    
120     protected override void setStruct(GObject* obj)
121     {
122         super.setStruct(obj);
123         gUnixFDList = cast(GUnixFDList*)obj;
124     }
125    
126     /**
127      */
128    
129     /**
130      * Creates a new GUnixFDList containing the file descriptors given in
131      * fds. The file descriptors become the property of the new list and
132      * may no longer be used by the caller. The array itself is owned by
133      * the caller.
134      * Each file descriptor in the array should be set to close-on-exec.
135      * If n_fds is -1 then fds must be terminated with -1.
136      * Since 2.24
137      * Params:
138      * fds = the initial list of file descriptors. [array length=n_fds]
139      * Throws: ConstructionException GTK+ fails to create the object.
140      */
141     public this (int[] fds)
142     {
143         // GUnixFDList * g_unix_fd_list_new_from_array (const gint *fds,  gint n_fds);
144         auto p = g_unix_fd_list_new_from_array(fds.ptr, cast(int) fds.length);
145         if(p is null)
146         {
147             throw new ConstructionException("null returned by g_unix_fd_list_new_from_array(fds.ptr, cast(int) fds.length)");
148         }
149         this(cast(GUnixFDList*) p);
150     }
151    
152     /**
153      * Creates a new GUnixFDList containing no file descriptors.
154      * Since 2.24
155      * Throws: ConstructionException GTK+ fails to create the object.
156      */
157     public this ()
158     {
159         // GUnixFDList * g_unix_fd_list_new (void);
160         auto p = g_unix_fd_list_new();
161         if(p is null)
162         {
163             throw new ConstructionException("null returned by g_unix_fd_list_new()");
164         }
165         this(cast(GUnixFDList*) p);
166     }
167    
168     /**
169      * Gets the length of list (ie: the number of file descriptors
170      * contained within).
171      * Since 2.24
172      * Returns: the length of list
173      */
174     public int getLength()
175     {
176         // gint g_unix_fd_list_get_length (GUnixFDList *list);
177         return g_unix_fd_list_get_length(gUnixFDList);
178     }
179    
180     /**
181      * Gets a file descriptor out of list.
182      * index_ specifies the index of the file descriptor to get. It is a
183      * programmer error for index_ to be out of range; see
184      * g_unix_fd_list_get_length().
185      * The file descriptor is duplicated using dup() and set as
186      * close-on-exec before being returned. You must call close() on it
187      * when you are done.
188      * A possible cause of failure is exceeding the per-process or
189      * system-wide file descriptor limit.
190      * Since 2.24
191      * Params:
192      * index = the index into the list
193      * Returns: the file descriptor, or -1 in case of error
194      * Throws: GException on failure.
195      */
196     public int get(int index)
197     {
198         // gint g_unix_fd_list_get (GUnixFDList *list,  gint index_,  GError **error);
199         GError* err = null;
200        
201         auto p = g_unix_fd_list_get(gUnixFDList, index, &err);
202        
203         if (err !is null)
204         {
205             throw new GException( new ErrorG(err) );
206         }
207        
208         return p;
209     }
210    
211     /**
212      * Returns the array of file descriptors that is contained in this
213      * object.
214      * After this call, the descriptors remain the property of list. The
215      * caller must not close them and must not free the array. The array is
216      * valid only until list is changed in any way.
217      * If length is non-NULL then it is set to the number of file
218      * descriptors in the returned array. The returned array is also
219      * terminated with -1.
220      * This function never returns NULL. In case there are no file
221      * descriptors contained in list, an empty array is returned.
222      * Since 2.24
223      * Returns: an array of file descriptors. [array length=length][transfer none]
224      */
225     public int[] peekFds()
226     {
227         // const gint * g_unix_fd_list_peek_fds (GUnixFDList *list,  gint *length);
228         int length;
229         auto p = g_unix_fd_list_peek_fds(gUnixFDList, &length);
230         return p[0 .. length];
231     }
232    
233     /**
234      * Returns the array of file descriptors that is contained in this
235      * object.
236      * After this call, the descriptors are no longer contained in
237      * list. Further calls will return an empty list (unless more
238      * descriptors have been added).
239      * The return result of this function must be freed with g_free().
240      * The caller is also responsible for closing all of the file
241      * descriptors. The file descriptors in the array are set to
242      * close-on-exec.
243      * If length is non-NULL then it is set to the number of file
244      * descriptors in the returned array. The returned array is also
245      * terminated with -1.
246      * This function never returns NULL. In case there are no file
247      * descriptors contained in list, an empty array is returned.
248      * Since 2.24
249      * Returns: an array of file descriptors. [array length=length][transfer full]
250      */
251     public int[] stealFds()
252     {
253         // gint * g_unix_fd_list_steal_fds (GUnixFDList *list,  gint *length);
254         int length;
255         auto p = g_unix_fd_list_steal_fds(gUnixFDList, &length);
256         return p[0 .. length];
257     }
258    
259     /**
260      * Adds a file descriptor to list.
261      * The file descriptor is duplicated using dup(). You keep your copy
262      * of the descriptor and the copy contained in list will be closed
263      * when list is finalized.
264      * A possible cause of failure is exceeding the per-process or
265      * system-wide file descriptor limit.
266      * The index of the file descriptor in the list is returned. If you use
267      * this index with g_unix_fd_list_get() then you will receive back a
268      * duplicated copy of the same file descriptor.
269      * Since 2.24
270      * Params:
271      * fd = a valid open file descriptor
272      * Returns: the index of the appended fd in case of success, else -1 (and error is set)
273      * Throws: GException on failure.
274      */
275     public int append(int fd)
276     {
277         // gint g_unix_fd_list_append (GUnixFDList *list,  gint fd,  GError **error);
278         GError* err = null;
279        
280         auto p = g_unix_fd_list_append(gUnixFDList, fd, &err);
281        
282         if (err !is null)
283         {
284             throw new GException( new ErrorG(err) );
285         }
286        
287         return p;
288     }
289 }
Note: See TracBrowser for help on using the browser.