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 private import gobject.ObjectG;
67 
68 private import glib.ErrorG;
69 private import glib.GException;
70 private import gio.SocketConnectableT;
71 private import gio.SocketConnectableIF;
72 
73 
74 private import gobject.ObjectG;
75 
76 /**
77  * GSocketAddress is the equivalent of struct sockaddr
78  * in the BSD sockets API. This is an abstract class; use
79  * GInetSocketAddress for internet sockets, or GUnixSocketAddress
80  * for UNIX domain sockets.
81  */
82 public class SocketAddress : ObjectG, SocketConnectableIF
83 {
84 	
85 	/** the main Gtk struct */
86 	protected GSocketAddress* gSocketAddress;
87 	
88 	
89 	/** Get the main Gtk struct */
90 	public GSocketAddress* getSocketAddressStruct()
91 	{
92 		return gSocketAddress;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected override void* getStruct()
98 	{
99 		return cast(void*)gSocketAddress;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (GSocketAddress* gSocketAddress)
106 	{
107 		super(cast(GObject*)gSocketAddress);
108 		this.gSocketAddress = gSocketAddress;
109 	}
110 	
111 	protected override void setStruct(GObject* obj)
112 	{
113 		super.setStruct(obj);
114 		gSocketAddress = cast(GSocketAddress*)obj;
115 	}
116 	
117 	// add the SocketConnectable capabilities
118 	mixin SocketConnectableT!(GSocketAddress);
119 	
120 	/**
121 	 */
122 	
123 	/**
124 	 * Creates a GSocketAddress subclass corresponding to the native
125 	 * struct sockaddr native.
126 	 * Since 2.22
127 	 * Params:
128 	 * native = a pointer to a struct sockaddr
129 	 * len = the size of the memory location pointed to by native
130 	 * Throws: ConstructionException GTK+ fails to create the object.
131 	 */
132 	public this (void* native, gsize len)
133 	{
134 		// GSocketAddress * g_socket_address_new_from_native (gpointer native,  gsize len);
135 		auto p = g_socket_address_new_from_native(native, len);
136 		if(p is null)
137 		{
138 			throw new ConstructionException("null returned by g_socket_address_new_from_native(native, len)");
139 		}
140 		this(cast(GSocketAddress*) p);
141 	}
142 	
143 	/**
144 	 * Gets the socket family type of address.
145 	 * Since 2.22
146 	 * Returns: the socket family type of address.
147 	 */
148 	public GSocketFamily getFamily()
149 	{
150 		// GSocketFamily g_socket_address_get_family (GSocketAddress *address);
151 		return g_socket_address_get_family(gSocketAddress);
152 	}
153 	
154 	/**
155 	 * Converts a GSocketAddress to a native struct
156 	 * sockaddr, which can be passed to low-level functions like
157 	 * connect() or bind().
158 	 * If not enough space is available, a G_IO_ERROR_NO_SPACE error is
159 	 * returned. If the address type is not known on the system
160 	 * then a G_IO_ERROR_NOT_SUPPORTED error is returned.
161 	 * Since 2.22
162 	 * Params:
163 	 * dest = a pointer to a memory location that will contain the native
164 	 * struct sockaddr.
165 	 * destlen = the size of dest. Must be at least as large as
166 	 * g_socket_address_get_native_size().
167 	 * Returns: TRUE if dest was filled in, FALSE on error
168 	 * Throws: GException on failure.
169 	 */
170 	public int toNative(void* dest, gsize destlen)
171 	{
172 		// gboolean g_socket_address_to_native (GSocketAddress *address,  gpointer dest,  gsize destlen,  GError **error);
173 		GError* err = null;
174 		
175 		auto p = g_socket_address_to_native(gSocketAddress, dest, destlen, &err);
176 		
177 		if (err !is null)
178 		{
179 			throw new GException( new ErrorG(err) );
180 		}
181 		
182 		return p;
183 	}
184 	
185 	/**
186 	 * Gets the size of address's native struct sockaddr.
187 	 * You can use this to allocate memory to pass to
188 	 * g_socket_address_to_native().
189 	 * Since 2.22
190 	 * Returns: the size of the native struct sockaddr that address represents
191 	 */
192 	public gssize getNativeSize()
193 	{
194 		// gssize g_socket_address_get_native_size (GSocketAddress *address);
195 		return g_socket_address_get_native_size(gSocketAddress);
196 	}
197 }