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