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 module gio.SimpleIOStream;
26 
27 private import gio.IOStream;
28 private import gio.InputStream;
29 private import gio.OutputStream;
30 private import glib.ConstructionException;
31 private import gobject.ObjectG;
32 private import gtkc.gio;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * GSimpleIOStream creates a #GIOStream from an arbitrary #GInputStream and
38  * #GOutputStream. This allows any pair of input and output streams to be used
39  * with #GIOStream methods.
40  * 
41  * This is useful when you obtained a #GInputStream and a #GOutputStream
42  * by other means, for instance creating them with platform specific methods as
43  * g_unix_input_stream_new() or g_win32_input_stream_new(), and you want
44  * to take advantage of the methods provided by #GIOStream.
45  *
46  * Since: 2.44
47  */
48 public class SimpleIOStream : IOStream
49 {
50 	/** the main Gtk struct */
51 	protected GSimpleIOStream* gSimpleIOStream;
52 
53 	/** Get the main Gtk struct */
54 	public GSimpleIOStream* getSimpleIOStreamStruct()
55 	{
56 		return gSimpleIOStream;
57 	}
58 
59 	/** the main Gtk struct as a void* */
60 	protected override void* getStruct()
61 	{
62 		return cast(void*)gSimpleIOStream;
63 	}
64 
65 	protected override void setStruct(GObject* obj)
66 	{
67 		gSimpleIOStream = cast(GSimpleIOStream*)obj;
68 		super.setStruct(obj);
69 	}
70 
71 	/**
72 	 * Sets our main struct and passes it to the parent class.
73 	 */
74 	public this (GSimpleIOStream* gSimpleIOStream, bool ownedRef = false)
75 	{
76 		this.gSimpleIOStream = gSimpleIOStream;
77 		super(cast(GIOStream*)gSimpleIOStream, ownedRef);
78 	}
79 
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return g_simple_io_stream_get_type();
85 	}
86 
87 	/**
88 	 * Creates a new #GSimpleIOStream wrapping @input_stream and @output_stream.
89 	 * See also #GIOStream.
90 	 *
91 	 * Params:
92 	 *     inputStream = a #GInputStream.
93 	 *     outputStream = a #GOutputStream.
94 	 *
95 	 * Return: a new #GSimpleIOStream instance.
96 	 *
97 	 * Since: 2.44
98 	 *
99 	 * Throws: ConstructionException GTK+ fails to create the object.
100 	 */
101 	public this(InputStream inputStream, OutputStream outputStream)
102 	{
103 		auto p = g_simple_io_stream_new((inputStream is null) ? null : inputStream.getInputStreamStruct(), (outputStream is null) ? null : outputStream.getOutputStreamStruct());
104 		
105 		if(p is null)
106 		{
107 			throw new ConstructionException("null returned by new");
108 		}
109 		
110 		this(cast(GSimpleIOStream*) p, true);
111 	}
112 }