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  * Conversion parameters:
26  * inFile  = GBufferedOutputStream.html
27  * outPack = gio
28  * outFile = BufferedOutputStream
29  * strct   = GBufferedOutputStream
30  * realStrct=
31  * ctorStrct=GOutputStream
32  * clss    = BufferedOutputStream
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_buffered_output_stream_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gio.OutputStream
47  * structWrap:
48  * 	- GOutputStream* -> OutputStream
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gio.BufferedOutputStream;
55 
56 public  import gtkc.giotypes;
57 
58 private import gtkc.gio;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 
63 private import gio.OutputStream;
64 
65 
66 
67 private import gio.FilterOutputStream;
68 
69 /**
70  * Description
71  * Buffered output stream implements GFilterOutputStream and provides
72  * for buffered writes.
73  * By default, GBufferedOutputStream's buffer size is set at 4 kilobytes.
74  * To create a buffered output stream, use g_buffered_output_stream_new(),
75  * or g_buffered_output_stream_new_sized() to specify the buffer's size
76  * at construction.
77  * To get the size of a buffer within a buffered input stream, use
78  * g_buffered_output_stream_get_buffer_size(). To change the size of a
79  * buffered output stream's buffer, use
80  * g_buffered_output_stream_set_buffer_size(). Note that the buffer's
81  * size cannot be reduced below the size of the data within the buffer.
82  */
83 public class BufferedOutputStream : FilterOutputStream
84 {
85 	
86 	/** the main Gtk struct */
87 	protected GBufferedOutputStream* gBufferedOutputStream;
88 	
89 	
90 	public GBufferedOutputStream* getBufferedOutputStreamStruct()
91 	{
92 		return gBufferedOutputStream;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected override void* getStruct()
98 	{
99 		return cast(void*)gBufferedOutputStream;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (GBufferedOutputStream* gBufferedOutputStream)
106 	{
107 		super(cast(GFilterOutputStream*)gBufferedOutputStream);
108 		this.gBufferedOutputStream = gBufferedOutputStream;
109 	}
110 	
111 	protected override void setStruct(GObject* obj)
112 	{
113 		super.setStruct(obj);
114 		gBufferedOutputStream = cast(GBufferedOutputStream*)obj;
115 	}
116 	
117 	/**
118 	 */
119 	
120 	/**
121 	 * Creates a new buffered output stream for a base stream.
122 	 * Params:
123 	 * baseStream = a GOutputStream.
124 	 * Throws: ConstructionException GTK+ fails to create the object.
125 	 */
126 	public this (OutputStream baseStream)
127 	{
128 		// GOutputStream * g_buffered_output_stream_new (GOutputStream *base_stream);
129 		auto p = g_buffered_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct());
130 		if(p is null)
131 		{
132 			throw new ConstructionException("null returned by g_buffered_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct())");
133 		}
134 		this(cast(GBufferedOutputStream*) p);
135 	}
136 	
137 	/**
138 	 * Creates a new buffered output stream with a given buffer size.
139 	 * Params:
140 	 * baseStream = a GOutputStream.
141 	 * size = a gsize.
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this (OutputStream baseStream, gsize size)
145 	{
146 		// GOutputStream * g_buffered_output_stream_new_sized (GOutputStream *base_stream,  gsize size);
147 		auto p = g_buffered_output_stream_new_sized((baseStream is null) ? null : baseStream.getOutputStreamStruct(), size);
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by g_buffered_output_stream_new_sized((baseStream is null) ? null : baseStream.getOutputStreamStruct(), size)");
151 		}
152 		this(cast(GBufferedOutputStream*) p);
153 	}
154 	
155 	/**
156 	 * Gets the size of the buffer in the stream.
157 	 * Returns: the current size of the buffer.
158 	 */
159 	public gsize getBufferSize()
160 	{
161 		// gsize g_buffered_output_stream_get_buffer_size  (GBufferedOutputStream *stream);
162 		return g_buffered_output_stream_get_buffer_size(gBufferedOutputStream);
163 	}
164 	
165 	/**
166 	 * Sets the size of the internal buffer to size.
167 	 * Params:
168 	 * size = a gsize.
169 	 */
170 	public void setBufferSize(gsize size)
171 	{
172 		// void g_buffered_output_stream_set_buffer_size  (GBufferedOutputStream *stream,  gsize size);
173 		g_buffered_output_stream_set_buffer_size(gBufferedOutputStream, size);
174 	}
175 	
176 	/**
177 	 * Checks if the buffer automatically grows as data is added.
178 	 * Returns: TRUE if the stream's buffer automatically grows, FALSE otherwise.
179 	 */
180 	public int getAutoGrow()
181 	{
182 		// gboolean g_buffered_output_stream_get_auto_grow  (GBufferedOutputStream *stream);
183 		return g_buffered_output_stream_get_auto_grow(gBufferedOutputStream);
184 	}
185 	
186 	/**
187 	 * Sets whether or not the stream's buffer should automatically grow.
188 	 * If auto_grow is true, then each write will just make the buffer
189 	 * larger, and you must manually flush the buffer to actually write out
190 	 * the data to the underlying stream.
191 	 * Params:
192 	 * autoGrow = a gboolean.
193 	 */
194 	public void setAutoGrow(int autoGrow)
195 	{
196 		// void g_buffered_output_stream_set_auto_grow  (GBufferedOutputStream *stream,  gboolean auto_grow);
197 		g_buffered_output_stream_set_auto_grow(gBufferedOutputStream, autoGrow);
198 	}
199 }