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