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(bool transferOwnership = false)
55 	{
56 		if (transferOwnership)
57 			ownedRef = false;
58 		return gSimpleIOStream;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gSimpleIOStream;
65 	}
66 
67 	protected override void setStruct(GObject* obj)
68 	{
69 		gSimpleIOStream = cast(GSimpleIOStream*)obj;
70 		super.setStruct(obj);
71 	}
72 
73 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GSimpleIOStream* gSimpleIOStream, bool ownedRef = false)
77 	{
78 		this.gSimpleIOStream = gSimpleIOStream;
79 		super(cast(GIOStream*)gSimpleIOStream, ownedRef);
80 	}
81 
82 
83 	/** */
84 	public static GType getType()
85 	{
86 		return g_simple_io_stream_get_type();
87 	}
88 
89 	/**
90 	 * Creates a new #GSimpleIOStream wrapping @input_stream and @output_stream.
91 	 * See also #GIOStream.
92 	 *
93 	 * Params:
94 	 *     inputStream = a #GInputStream.
95 	 *     outputStream = a #GOutputStream.
96 	 *
97 	 * Returns: a new #GSimpleIOStream instance.
98 	 *
99 	 * Since: 2.44
100 	 *
101 	 * Throws: ConstructionException GTK+ fails to create the object.
102 	 */
103 	public this(InputStream inputStream, OutputStream outputStream)
104 	{
105 		auto p = g_simple_io_stream_new((inputStream is null) ? null : inputStream.getInputStreamStruct(), (outputStream is null) ? null : outputStream.getOutputStreamStruct());
106 		
107 		if(p is null)
108 		{
109 			throw new ConstructionException("null returned by new");
110 		}
111 		
112 		this(cast(GSimpleIOStream*) p, true);
113 	}
114 }