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.ConverterInputStream;
26 
27 private import gio.Converter;
28 private import gio.ConverterIF;
29 private import gio.FilterInputStream;
30 private import gio.InputStream;
31 private import gio.PollableInputStreamIF;
32 private import gio.PollableInputStreamT;
33 private import glib.ConstructionException;
34 private import gobject.ObjectG;
35 private import gtkc.gio;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * Converter input stream implements #GInputStream and allows
41  * conversion of data of various types during reading.
42  * 
43  * As of GLib 2.34, #GConverterInputStream implements
44  * #GPollableInputStream.
45  */
46 public class ConverterInputStream : FilterInputStream, PollableInputStreamIF
47 {
48 	/** the main Gtk struct */
49 	protected GConverterInputStream* gConverterInputStream;
50 
51 	/** Get the main Gtk struct */
52 	public GConverterInputStream* getConverterInputStreamStruct()
53 	{
54 		return gConverterInputStream;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gConverterInputStream;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gConverterInputStream = cast(GConverterInputStream*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GConverterInputStream* gConverterInputStream, bool ownedRef = false)
73 	{
74 		this.gConverterInputStream = gConverterInputStream;
75 		super(cast(GFilterInputStream*)gConverterInputStream, ownedRef);
76 	}
77 
78 	// add the PollableInputStream capabilities
79 	mixin PollableInputStreamT!(GConverterInputStream);
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return g_converter_input_stream_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new converter input stream for the @base_stream.
90 	 *
91 	 * Params:
92 	 *     baseStream = a #GInputStream
93 	 *     converter = a #GConverter
94 	 *
95 	 * Return: a new #GInputStream.
96 	 *
97 	 * Throws: ConstructionException GTK+ fails to create the object.
98 	 */
99 	public this(InputStream baseStream, ConverterIF converter)
100 	{
101 		auto p = g_converter_input_stream_new((baseStream is null) ? null : baseStream.getInputStreamStruct(), (converter is null) ? null : converter.getConverterStruct());
102 		
103 		if(p is null)
104 		{
105 			throw new ConstructionException("null returned by new");
106 		}
107 		
108 		this(cast(GConverterInputStream*) p, true);
109 	}
110 
111 	/**
112 	 * Gets the #GConverter that is used by @converter_stream.
113 	 *
114 	 * Return: the converter of the converter input stream
115 	 *
116 	 * Since: 2.24
117 	 */
118 	public ConverterIF getConverter()
119 	{
120 		auto p = g_converter_input_stream_get_converter(gConverterInputStream);
121 		
122 		if(p is null)
123 		{
124 			return null;
125 		}
126 		
127 		return ObjectG.getDObject!(Converter, ConverterIF)(cast(GConverter*) p);
128 	}
129 }