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 private import gio.OutputStream;
63 
64 
65 private import gio.FilterOutputStream;
66 
67 /**
68  * Buffered output stream implements GFilterOutputStream and provides
69  * for buffered writes.
70  *
71  * By default, GBufferedOutputStream's buffer size is set at 4 kilobytes.
72  *
73  * To create a buffered output stream, use g_buffered_output_stream_new(),
74  * or g_buffered_output_stream_new_sized() to specify the buffer's size
75  * at construction.
76  *
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 	/** Get the main Gtk struct */
91 	public GBufferedOutputStream* getBufferedOutputStreamStruct()
92 	{
93 		return gBufferedOutputStream;
94 	}
95 	
96 	
97 	/** the main Gtk struct as a void* */
98 	protected override void* getStruct()
99 	{
100 		return cast(void*)gBufferedOutputStream;
101 	}
102 	
103 	/**
104 	 * Sets our main struct and passes it to the parent class
105 	 */
106 	public this (GBufferedOutputStream* gBufferedOutputStream)
107 	{
108 		super(cast(GFilterOutputStream*)gBufferedOutputStream);
109 		this.gBufferedOutputStream = gBufferedOutputStream;
110 	}
111 	
112 	protected override void setStruct(GObject* obj)
113 	{
114 		super.setStruct(obj);
115 		gBufferedOutputStream = cast(GBufferedOutputStream*)obj;
116 	}
117 	
118 	/**
119 	 */
120 	
121 	/**
122 	 * Creates a new buffered output stream for a base stream.
123 	 * Params:
124 	 * baseStream = a GOutputStream.
125 	 * Throws: ConstructionException GTK+ fails to create the object.
126 	 */
127 	public this (OutputStream baseStream)
128 	{
129 		// GOutputStream * g_buffered_output_stream_new (GOutputStream *base_stream);
130 		auto p = g_buffered_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct());
131 		if(p is null)
132 		{
133 			throw new ConstructionException("null returned by g_buffered_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct())");
134 		}
135 		this(cast(GBufferedOutputStream*) p);
136 	}
137 	
138 	/**
139 	 * Creates a new buffered output stream with a given buffer size.
140 	 * Params:
141 	 * baseStream = a GOutputStream.
142 	 * size = a gsize.
143 	 * Throws: ConstructionException GTK+ fails to create the object.
144 	 */
145 	public this (OutputStream baseStream, gsize size)
146 	{
147 		// GOutputStream * g_buffered_output_stream_new_sized (GOutputStream *base_stream,  gsize size);
148 		auto p = g_buffered_output_stream_new_sized((baseStream is null) ? null : baseStream.getOutputStreamStruct(), size);
149 		if(p is null)
150 		{
151 			throw new ConstructionException("null returned by g_buffered_output_stream_new_sized((baseStream is null) ? null : baseStream.getOutputStreamStruct(), size)");
152 		}
153 		this(cast(GBufferedOutputStream*) p);
154 	}
155 	
156 	/**
157 	 * Gets the size of the buffer in the stream.
158 	 * Returns: the current size of the buffer.
159 	 */
160 	public gsize getBufferSize()
161 	{
162 		// gsize g_buffered_output_stream_get_buffer_size  (GBufferedOutputStream *stream);
163 		return g_buffered_output_stream_get_buffer_size(gBufferedOutputStream);
164 	}
165 	
166 	/**
167 	 * Sets the size of the internal buffer to size.
168 	 * Params:
169 	 * size = a gsize.
170 	 */
171 	public void setBufferSize(gsize size)
172 	{
173 		// void g_buffered_output_stream_set_buffer_size  (GBufferedOutputStream *stream,  gsize size);
174 		g_buffered_output_stream_set_buffer_size(gBufferedOutputStream, size);
175 	}
176 	
177 	/**
178 	 * Checks if the buffer automatically grows as data is added.
179 	 * Returns: TRUE if the stream's buffer automatically grows, FALSE otherwise.
180 	 */
181 	public int getAutoGrow()
182 	{
183 		// gboolean g_buffered_output_stream_get_auto_grow  (GBufferedOutputStream *stream);
184 		return g_buffered_output_stream_get_auto_grow(gBufferedOutputStream);
185 	}
186 	
187 	/**
188 	 * Sets whether or not the stream's buffer should automatically grow.
189 	 * If auto_grow is true, then each write will just make the buffer
190 	 * larger, and you must manually flush the buffer to actually write out
191 	 * the data to the underlying stream.
192 	 * Params:
193 	 * autoGrow = a gboolean.
194 	 */
195 	public void setAutoGrow(int autoGrow)
196 	{
197 		// void g_buffered_output_stream_set_auto_grow  (GBufferedOutputStream *stream,  gboolean auto_grow);
198 		g_buffered_output_stream_set_auto_grow(gBufferedOutputStream, autoGrow);
199 	}
200 }