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