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