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