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  = GInetSocketAddress.html
27  * outPack = gio
28  * outFile = InetSocketAddress
29  * strct   = GInetSocketAddress
30  * realStrct=
31  * ctorStrct=GSocketAddress
32  * clss    = InetSocketAddress
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_inet_socket_address_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gio.InetAddress
47  * structWrap:
48  * 	- GInetAddress* -> InetAddress
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gio.InetSocketAddress;
55 
56 public  import gtkc.giotypes;
57 
58 private import gtkc.gio;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 
63 private import gio.InetAddress;
64 
65 
66 
67 private import gio.SocketAddress;
68 
69 /**
70  * Description
71  * An IPv4 or IPv6 socket address; that is, the combination of a
72  * GInetAddress and a port number.
73  */
74 public class InetSocketAddress : SocketAddress
75 {
76 	
77 	/** the main Gtk struct */
78 	protected GInetSocketAddress* gInetSocketAddress;
79 	
80 	
81 	public GInetSocketAddress* getInetSocketAddressStruct()
82 	{
83 		return gInetSocketAddress;
84 	}
85 	
86 	
87 	/** the main Gtk struct as a void* */
88 	protected override void* getStruct()
89 	{
90 		return cast(void*)gInetSocketAddress;
91 	}
92 	
93 	/**
94 	 * Sets our main struct and passes it to the parent class
95 	 */
96 	public this (GInetSocketAddress* gInetSocketAddress)
97 	{
98 		super(cast(GSocketAddress*)gInetSocketAddress);
99 		this.gInetSocketAddress = gInetSocketAddress;
100 	}
101 	
102 	protected override void setStruct(GObject* obj)
103 	{
104 		super.setStruct(obj);
105 		gInetSocketAddress = cast(GInetSocketAddress*)obj;
106 	}
107 	
108 	/**
109 	 */
110 	
111 	/**
112 	 * Creates a new GInetSocketAddress for address and port.
113 	 * Since 2.22
114 	 * Params:
115 	 * address = a GInetAddress
116 	 * port = a port number
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this (InetAddress address, ushort port)
120 	{
121 		// GSocketAddress * g_inet_socket_address_new (GInetAddress *address,  guint16 port);
122 		auto p = g_inet_socket_address_new((address is null) ? null : address.getInetAddressStruct(), port);
123 		if(p is null)
124 		{
125 			throw new ConstructionException("null returned by g_inet_socket_address_new((address is null) ? null : address.getInetAddressStruct(), port)");
126 		}
127 		this(cast(GInetSocketAddress*) p);
128 	}
129 	
130 	/**
131 	 * Gets address's GInetAddress.
132 	 * Since 2.22
133 	 * Returns: the GInetAddress for address, which must be g_object_ref()'d if it will be stored. [transfer none]
134 	 */
135 	public InetAddress getAddress()
136 	{
137 		// GInetAddress * g_inet_socket_address_get_address (GInetSocketAddress *address);
138 		auto p = g_inet_socket_address_get_address(gInetSocketAddress);
139 		
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 		
145 		return ObjectG.getDObject!(InetAddress)(cast(GInetAddress*) p);
146 	}
147 	
148 	/**
149 	 * Gets address's port.
150 	 * Since 2.22
151 	 * Returns: the port for address
152 	 */
153 	public ushort getPort()
154 	{
155 		// guint16 g_inet_socket_address_get_port (GInetSocketAddress *address);
156 		return g_inet_socket_address_get_port(gInetSocketAddress);
157 	}
158 }