root/trunk/src/gio/SocketAddress.d

Revision 937, 5.4 kB (checked in by Mike Wey, 3 months ago)

Mention the exceptions to the LGPL in the source files.

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  = GSocketAddress.html
27  * outPack = gio
28  * outFile = SocketAddress
29  * strct   = GSocketAddress
30  * realStrct=
31  * ctorStrct=
32  * clss    = SocketAddress
33  * interf  =
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  =
38  * implements:
39  *  - SocketConnectableIF
40  * prefixes:
41  *  - g_socket_address_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  *  - glib.ErrorG
48  *  - glib.GException
49  *  - gio.SocketConnectableT
50  *  - gio.SocketConnectableIF
51  * structWrap:
52  * module aliases:
53  * local aliases:
54  *  - GLIB_SYSDEF_AF_INET -> 2
55  *  - GLIB_SYSDEF_AF_INET6 -> 23
56  *  - GLIB_SYSDEF_AF_UNIX -> 1
57  * overrides:
58  */
59
60 module gio.SocketAddress;
61
62 public  import gtkc.giotypes;
63
64 private import gtkc.gio;
65 private import glib.ConstructionException;
66
67
68 private import glib.ErrorG;
69 private import glib.GException;
70 private import gio.SocketConnectableT;
71 private import gio.SocketConnectableIF;
72
73
74
75 private import gobject.ObjectG;
76
77 /**
78  * Description
79  * GSocketAddress is the equivalent of struct sockaddr
80  * in the BSD sockets API. This is an abstract class; use
81  * GInetSocketAddress for internet sockets, or GUnixSocketAddress
82  * for UNIX domain sockets.
83  */
84 public class SocketAddress : ObjectG, SocketConnectableIF
85 {
86    
87     /** the main Gtk struct */
88     protected GSocketAddress* gSocketAddress;
89    
90    
91     public GSocketAddress* getSocketAddressStruct()
92     {
93         return gSocketAddress;
94     }
95    
96    
97     /** the main Gtk struct as a void* */
98     protected override void* getStruct()
99     {
100         return cast(void*)gSocketAddress;
101     }
102    
103     /**
104      * Sets our main struct and passes it to the parent class
105      */
106     public this (GSocketAddress* gSocketAddress)
107     {
108         if(gSocketAddress is null)
109         {
110             this = null;
111             return;
112         }
113         //Check if there already is a D object for this gtk struct
114         void* ptr = getDObject(cast(GObject*)gSocketAddress);
115         if( ptr !is null )
116         {
117             this = cast(SocketAddress)ptr;
118             return;
119         }
120         super(cast(GObject*)gSocketAddress);
121         this.gSocketAddress = gSocketAddress;
122     }
123    
124     protected override void setStruct(GObject* obj)
125     {
126         super.setStruct(obj);
127         gSocketAddress = cast(GSocketAddress*)obj;
128     }
129    
130     // add the SocketConnectable capabilities
131     mixin SocketConnectableT!(GSocketAddress);
132    
133     /**
134      */
135    
136     /**
137      * Creates a GSocketAddress subclass corresponding to the native
138      * struct sockaddr native.
139      * Since 2.22
140      * Params:
141      * native = a pointer to a struct sockaddr
142      * len = the size of the memory location pointed to by native
143      * Throws: ConstructionException GTK+ fails to create the object.
144      */
145     public this (void* native, gsize len)
146     {
147         // GSocketAddress * g_socket_address_new_from_native (gpointer native,  gsize len);
148         auto p = g_socket_address_new_from_native(native, len);
149         if(p is null)
150         {
151             throw new ConstructionException("null returned by g_socket_address_new_from_native(native, len)");
152         }
153         this(cast(GSocketAddress*) p);
154     }
155    
156     /**
157      * Gets the socket family type of address.
158      * Since 2.22
159      * Returns: the socket family type of address.
160      */
161     public GSocketFamily getFamily()
162     {
163         // GSocketFamily g_socket_address_get_family (GSocketAddress *address);
164         return g_socket_address_get_family(gSocketAddress);
165     }
166    
167     /**
168      * Converts a GSocketAddress to a native struct
169      * sockaddr, which can be passed to low-level functions like
170      * connect() or bind().
171      * If not enough space is availible, a G_IO_ERROR_NO_SPACE error is
172      * returned. If the address type is not known on the system
173      * then a G_IO_ERROR_NOT_SUPPORTED error is returned.
174      * Since 2.22
175      * Params:
176      * dest = a pointer to a memory location that will contain the native
177      * struct sockaddr.
178      * destlen = the size of dest. Must be at least as large as
179      * g_socket_address_get_native_size().
180      * Returns: TRUE if dest was filled in, FALSE on error
181      * Throws: GException on failure.
182      */
183     public int toNative(void* dest, gsize destlen)
184     {
185         // gboolean g_socket_address_to_native (GSocketAddress *address,  gpointer dest,  gsize destlen,  GError **error);
186         GError* err = null;
187        
188         auto p = g_socket_address_to_native(gSocketAddress, dest, destlen, &err);
189        
190         if (err !is null)
191         {
192             throw new GException( new ErrorG(err) );
193         }
194        
195         return p;
196     }
197    
198     /**
199      * Gets the size of address's native struct sockaddr.
200      * You can use this to allocate memory to pass to
201      * g_socket_address_to_native().
202      * Since 2.22
203      * Returns: the size of the native struct sockaddr that address represents
204      */
205     public gssize getNativeSize()
206     {
207         // gssize g_socket_address_get_native_size (GSocketAddress *address);
208         return g_socket_address_get_native_size(gSocketAddress);
209     }
210 }
Note: See TracBrowser for help on using the browser.