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  = gio-GInetAddressMask.html
27  * outPack = gio
28  * outFile = InetAddressMask
29  * strct   = GInetAddressMask
30  * realStrct=
31  * ctorStrct=
32  * clss    = InetAddressMask
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GObject
38  * implements:
39  * prefixes:
40  * 	- g_inet_address_mask_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- gio.InetAddress
50  * structWrap:
51  * 	- GInetAddress* -> InetAddress
52  * 	- GInetAddressMask* -> InetAddressMask
53  * module aliases:
54  * local aliases:
55  * overrides:
56  * 	- toString
57  */
58 
59 module gio.InetAddressMask;
60 
61 public  import gtkc.giotypes;
62 
63 private import gtkc.gio;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 
68 private import glib.Str;
69 private import glib.ErrorG;
70 private import glib.GException;
71 private import gio.InetAddress;
72 
73 
74 
75 private import gobject.ObjectG;
76 
77 /**
78  * GInetAddressMask represents a range of IPv4 or IPv6 addresses
79  * described by a base address and a length indicating how many bits
80  * of the base address are relevant for matching purposes. These are
81  * often given in string form. Eg, "10.0.0.0/8", or "fe80::/10".
82  */
83 public class InetAddressMask : ObjectG
84 {
85 	
86 	/** the main Gtk struct */
87 	protected GInetAddressMask* gInetAddressMask;
88 	
89 	
90 	public GInetAddressMask* getInetAddressMaskStruct()
91 	{
92 		return gInetAddressMask;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected override void* getStruct()
98 	{
99 		return cast(void*)gInetAddressMask;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (GInetAddressMask* gInetAddressMask)
106 	{
107 		super(cast(GObject*)gInetAddressMask);
108 		this.gInetAddressMask = gInetAddressMask;
109 	}
110 	
111 	protected override void setStruct(GObject* obj)
112 	{
113 		super.setStruct(obj);
114 		gInetAddressMask = cast(GInetAddressMask*)obj;
115 	}
116 	
117 	/**
118 	 */
119 	
120 	/**
121 	 * Creates a new GInetAddressMask representing all addresses whose
122 	 * first length bits match addr.
123 	 * Since 2.32
124 	 * Params:
125 	 * addr = a GInetAddress
126 	 * length = number of bits of addr to use
127 	 * Throws: GException on failure.
128 	 * Throws: ConstructionException GTK+ fails to create the object.
129 	 */
130 	public this (InetAddress addr, uint length)
131 	{
132 		// GInetAddressMask * g_inet_address_mask_new (GInetAddress *addr,  guint length,  GError **error);
133 		GError* err = null;
134 		
135 		auto p = g_inet_address_mask_new((addr is null) ? null : addr.getInetAddressStruct(), length, &err);
136 		
137 		if (err !is null)
138 		{
139 			throw new GException( new ErrorG(err) );
140 		}
141 		
142 		if(p is null)
143 		{
144 			throw new ConstructionException("null returned by g_inet_address_mask_new((addr is null) ? null : addr.getInetAddressStruct(), length, &err)");
145 		}
146 		this(cast(GInetAddressMask*) p);
147 	}
148 	
149 	/**
150 	 * Parses mask_string as an IP address and (optional) length, and
151 	 * creates a new GInetAddressMask. The length, if present, is
152 	 * delimited by a "/". If it is not present, then the length is
153 	 * assumed to be the full length of the address.
154 	 * Since 2.32
155 	 * Params:
156 	 * maskString = an IP address or address/length string
157 	 * Throws: GException on failure.
158 	 * Throws: ConstructionException GTK+ fails to create the object.
159 	 */
160 	public this (string maskString)
161 	{
162 		// GInetAddressMask * g_inet_address_mask_new_from_string (const gchar *mask_string,  GError **error);
163 		GError* err = null;
164 		
165 		auto p = g_inet_address_mask_new_from_string(Str.toStringz(maskString), &err);
166 		
167 		if (err !is null)
168 		{
169 			throw new GException( new ErrorG(err) );
170 		}
171 		
172 		if(p is null)
173 		{
174 			throw new ConstructionException("null returned by g_inet_address_mask_new_from_string(Str.toStringz(maskString), &err)");
175 		}
176 		this(cast(GInetAddressMask*) p);
177 	}
178 	
179 	/**
180 	 * Converts mask back to its corresponding string form.
181 	 * Since 2.32
182 	 * Returns: a string corresponding to mask.
183 	 */
184 	public override string toString()
185 	{
186 		// gchar * g_inet_address_mask_to_string (GInetAddressMask *mask);
187 		return Str.toString(g_inet_address_mask_to_string(gInetAddressMask));
188 	}
189 	
190 	/**
191 	 * Gets the GSocketFamily of mask's address
192 	 * Since 2.32
193 	 * Returns: the GSocketFamily of mask's address
194 	 */
195 	public GSocketFamily getFamily()
196 	{
197 		// GSocketFamily g_inet_address_mask_get_family (GInetAddressMask *mask);
198 		return g_inet_address_mask_get_family(gInetAddressMask);
199 	}
200 	
201 	/**
202 	 * Gets mask's base address
203 	 * Since 2.32
204 	 * Returns: mask's base address. [transfer none]
205 	 */
206 	public InetAddress getAddress()
207 	{
208 		// GInetAddress * g_inet_address_mask_get_address (GInetAddressMask *mask);
209 		auto p = g_inet_address_mask_get_address(gInetAddressMask);
210 		
211 		if(p is null)
212 		{
213 			return null;
214 		}
215 		
216 		return ObjectG.getDObject!(InetAddress)(cast(GInetAddress*) p);
217 	}
218 	
219 	/**
220 	 * Gets mask's length
221 	 * Since 2.32
222 	 * Returns: mask's length
223 	 */
224 	public uint getLength()
225 	{
226 		// guint g_inet_address_mask_get_length (GInetAddressMask *mask);
227 		return g_inet_address_mask_get_length(gInetAddressMask);
228 	}
229 	
230 	/**
231 	 * Tests if address falls within the range described by mask.
232 	 * Since 2.32
233 	 * Params:
234 	 * address = a GInetAddress
235 	 * Returns: whether address falls within the range described by mask.
236 	 */
237 	public int matches(InetAddress address)
238 	{
239 		// gboolean g_inet_address_mask_matches (GInetAddressMask *mask,  GInetAddress *address);
240 		return g_inet_address_mask_matches(gInetAddressMask, (address is null) ? null : address.getInetAddressStruct());
241 	}
242 	
243 	/**
244 	 * Tests if mask and mask2 are the same mask.
245 	 * Since 2.32
246 	 * Params:
247 	 * mask = a GInetAddressMask
248 	 * mask2 = another GInetAddressMask
249 	 * Returns: whether mask and mask2 are the same mask
250 	 */
251 	public int equal(InetAddressMask mask2)
252 	{
253 		// gboolean g_inet_address_mask_equal (GInetAddressMask *mask,  GInetAddressMask *mask2);
254 		return g_inet_address_mask_equal(gInetAddressMask, (mask2 is null) ? null : mask2.getInetAddressMaskStruct());
255 	}
256 }