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