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.DataOutputStream;
26 
27 private import gio.Cancellable;
28 private import gio.FilterOutputStream;
29 private import gio.OutputStream;
30 private import gio.SeekableIF;
31 private import gio.SeekableT;
32 private import glib.ConstructionException;
33 private import glib.ErrorG;
34 private import glib.GException;
35 private import glib.Str;
36 private import gobject.ObjectG;
37 private import gtkc.gio;
38 public  import gtkc.giotypes;
39 
40 
41 /**
42  * Data output stream implements #GOutputStream and includes functions for
43  * writing data directly to an output stream.
44  */
45 public class DataOutputStream : FilterOutputStream, SeekableIF
46 {
47 	/** the main Gtk struct */
48 	protected GDataOutputStream* gDataOutputStream;
49 
50 	/** Get the main Gtk struct */
51 	public GDataOutputStream* getDataOutputStreamStruct()
52 	{
53 		return gDataOutputStream;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gDataOutputStream;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		gDataOutputStream = cast(GDataOutputStream*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GDataOutputStream* gDataOutputStream, bool ownedRef = false)
72 	{
73 		this.gDataOutputStream = gDataOutputStream;
74 		super(cast(GFilterOutputStream*)gDataOutputStream, ownedRef);
75 	}
76 
77 	// add the Seekable capabilities
78 	mixin SeekableT!(GDataOutputStream);
79 
80 	/**
81 	 */
82 
83 	public static GType getType()
84 	{
85 		return g_data_output_stream_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new data output stream for @base_stream.
90 	 *
91 	 * Params:
92 	 *     baseStream = a #GOutputStream.
93 	 *
94 	 * Return: #GDataOutputStream.
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this(OutputStream baseStream)
99 	{
100 		auto p = g_data_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct());
101 		
102 		if(p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 		
107 		this(cast(GDataOutputStream*) p, true);
108 	}
109 
110 	/**
111 	 * Gets the byte order for the stream.
112 	 *
113 	 * Return: the #GDataStreamByteOrder for the @stream.
114 	 */
115 	public GDataStreamByteOrder getByteOrder()
116 	{
117 		return g_data_output_stream_get_byte_order(gDataOutputStream);
118 	}
119 
120 	/**
121 	 * Puts a byte into the output stream.
122 	 *
123 	 * Params:
124 	 *     data = a #guchar.
125 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
126 	 *
127 	 * Return: %TRUE if @data was successfully added to the @stream.
128 	 *
129 	 * Throws: GException on failure.
130 	 */
131 	public bool putByte(char data, Cancellable cancellable)
132 	{
133 		GError* err = null;
134 		
135 		auto p = g_data_output_stream_put_byte(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
136 		
137 		if (err !is null)
138 		{
139 			throw new GException( new ErrorG(err) );
140 		}
141 		
142 		return p;
143 	}
144 
145 	/**
146 	 * Puts a signed 16-bit integer into the output stream.
147 	 *
148 	 * Params:
149 	 *     data = a #gint16.
150 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
151 	 *
152 	 * Return: %TRUE if @data was successfully added to the @stream.
153 	 *
154 	 * Throws: GException on failure.
155 	 */
156 	public bool putInt16(short data, Cancellable cancellable)
157 	{
158 		GError* err = null;
159 		
160 		auto p = g_data_output_stream_put_int16(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
161 		
162 		if (err !is null)
163 		{
164 			throw new GException( new ErrorG(err) );
165 		}
166 		
167 		return p;
168 	}
169 
170 	/**
171 	 * Puts a signed 32-bit integer into the output stream.
172 	 *
173 	 * Params:
174 	 *     data = a #gint32.
175 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
176 	 *
177 	 * Return: %TRUE if @data was successfully added to the @stream.
178 	 *
179 	 * Throws: GException on failure.
180 	 */
181 	public bool putInt32(int data, Cancellable cancellable)
182 	{
183 		GError* err = null;
184 		
185 		auto p = g_data_output_stream_put_int32(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
186 		
187 		if (err !is null)
188 		{
189 			throw new GException( new ErrorG(err) );
190 		}
191 		
192 		return p;
193 	}
194 
195 	/**
196 	 * Puts a signed 64-bit integer into the stream.
197 	 *
198 	 * Params:
199 	 *     data = a #gint64.
200 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
201 	 *
202 	 * Return: %TRUE if @data was successfully added to the @stream.
203 	 *
204 	 * Throws: GException on failure.
205 	 */
206 	public bool putInt64(long data, Cancellable cancellable)
207 	{
208 		GError* err = null;
209 		
210 		auto p = g_data_output_stream_put_int64(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
211 		
212 		if (err !is null)
213 		{
214 			throw new GException( new ErrorG(err) );
215 		}
216 		
217 		return p;
218 	}
219 
220 	/**
221 	 * Puts a string into the output stream.
222 	 *
223 	 * Params:
224 	 *     str = a string.
225 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
226 	 *
227 	 * Return: %TRUE if @string was successfully added to the @stream.
228 	 *
229 	 * Throws: GException on failure.
230 	 */
231 	public bool putString(string str, Cancellable cancellable)
232 	{
233 		GError* err = null;
234 		
235 		auto p = g_data_output_stream_put_string(gDataOutputStream, Str.toStringz(str), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
236 		
237 		if (err !is null)
238 		{
239 			throw new GException( new ErrorG(err) );
240 		}
241 		
242 		return p;
243 	}
244 
245 	/**
246 	 * Puts an unsigned 16-bit integer into the output stream.
247 	 *
248 	 * Params:
249 	 *     data = a #guint16.
250 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
251 	 *
252 	 * Return: %TRUE if @data was successfully added to the @stream.
253 	 *
254 	 * Throws: GException on failure.
255 	 */
256 	public bool putUint16(ushort data, Cancellable cancellable)
257 	{
258 		GError* err = null;
259 		
260 		auto p = g_data_output_stream_put_uint16(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
261 		
262 		if (err !is null)
263 		{
264 			throw new GException( new ErrorG(err) );
265 		}
266 		
267 		return p;
268 	}
269 
270 	/**
271 	 * Puts an unsigned 32-bit integer into the stream.
272 	 *
273 	 * Params:
274 	 *     data = a #guint32.
275 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
276 	 *
277 	 * Return: %TRUE if @data was successfully added to the @stream.
278 	 *
279 	 * Throws: GException on failure.
280 	 */
281 	public bool putUint32(uint data, Cancellable cancellable)
282 	{
283 		GError* err = null;
284 		
285 		auto p = g_data_output_stream_put_uint32(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
286 		
287 		if (err !is null)
288 		{
289 			throw new GException( new ErrorG(err) );
290 		}
291 		
292 		return p;
293 	}
294 
295 	/**
296 	 * Puts an unsigned 64-bit integer into the stream.
297 	 *
298 	 * Params:
299 	 *     data = a #guint64.
300 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
301 	 *
302 	 * Return: %TRUE if @data was successfully added to the @stream.
303 	 *
304 	 * Throws: GException on failure.
305 	 */
306 	public bool putUint64(ulong data, Cancellable cancellable)
307 	{
308 		GError* err = null;
309 		
310 		auto p = g_data_output_stream_put_uint64(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
311 		
312 		if (err !is null)
313 		{
314 			throw new GException( new ErrorG(err) );
315 		}
316 		
317 		return p;
318 	}
319 
320 	/**
321 	 * Sets the byte order of the data output stream to @order.
322 	 *
323 	 * Params:
324 	 *     order = a %GDataStreamByteOrder.
325 	 */
326 	public void setByteOrder(GDataStreamByteOrder order)
327 	{
328 		g_data_output_stream_set_byte_order(gDataOutputStream, order);
329 	}
330 }