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.DataInputStream;
26 
27 private import gio.AsyncResultIF;
28 private import gio.BufferedInputStream;
29 private import gio.Cancellable;
30 private import gio.InputStream;
31 private import glib.ConstructionException;
32 private import glib.ErrorG;
33 private import glib.GException;
34 private import glib.Str;
35 private import gobject.ObjectG;
36 private import gtkc.gio;
37 public  import gtkc.giotypes;
38 
39 
40 /**
41  * Data input stream implements #GInputStream and includes functions for
42  * reading structured data directly from a binary input stream.
43  */
44 public class DataInputStream : BufferedInputStream
45 {
46 	/** the main Gtk struct */
47 	protected GDataInputStream* gDataInputStream;
48 
49 	/** Get the main Gtk struct */
50 	public GDataInputStream* getDataInputStreamStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gDataInputStream;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gDataInputStream;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gDataInputStream = cast(GDataInputStream*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GDataInputStream* gDataInputStream, bool ownedRef = false)
73 	{
74 		this.gDataInputStream = gDataInputStream;
75 		super(cast(GBufferedInputStream*)gDataInputStream, ownedRef);
76 	}
77 
78 
79 	/** */
80 	public static GType getType()
81 	{
82 		return g_data_input_stream_get_type();
83 	}
84 
85 	/**
86 	 * Creates a new data input stream for the @base_stream.
87 	 *
88 	 * Params:
89 	 *     baseStream = a #GInputStream.
90 	 *
91 	 * Returns: a new #GDataInputStream.
92 	 *
93 	 * Throws: ConstructionException GTK+ fails to create the object.
94 	 */
95 	public this(InputStream baseStream)
96 	{
97 		auto p = g_data_input_stream_new((baseStream is null) ? null : baseStream.getInputStreamStruct());
98 		
99 		if(p is null)
100 		{
101 			throw new ConstructionException("null returned by new");
102 		}
103 		
104 		this(cast(GDataInputStream*) p, true);
105 	}
106 
107 	/**
108 	 * Gets the byte order for the data input stream.
109 	 *
110 	 * Returns: the @stream's current #GDataStreamByteOrder.
111 	 */
112 	public GDataStreamByteOrder getByteOrder()
113 	{
114 		return g_data_input_stream_get_byte_order(gDataInputStream);
115 	}
116 
117 	/**
118 	 * Gets the current newline type for the @stream.
119 	 *
120 	 * Returns: #GDataStreamNewlineType for the given @stream.
121 	 */
122 	public GDataStreamNewlineType getNewlineType()
123 	{
124 		return g_data_input_stream_get_newline_type(gDataInputStream);
125 	}
126 
127 	/**
128 	 * Reads a 16-bit/2-byte value from @stream.
129 	 *
130 	 * In order to get the correct byte order for this read operation,
131 	 * see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
132 	 *
133 	 * Params:
134 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
135 	 *
136 	 * Returns: a signed 16-bit/2-byte value read from @stream or %0 if
137 	 *     an error occurred.
138 	 *
139 	 * Throws: GException on failure.
140 	 */
141 	public short readInt16(Cancellable cancellable)
142 	{
143 		GError* err = null;
144 		
145 		auto p = g_data_input_stream_read_int16(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
146 		
147 		if (err !is null)
148 		{
149 			throw new GException( new ErrorG(err) );
150 		}
151 		
152 		return p;
153 	}
154 
155 	/**
156 	 * Reads a signed 32-bit/4-byte value from @stream.
157 	 *
158 	 * In order to get the correct byte order for this read operation,
159 	 * see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
160 	 *
161 	 * If @cancellable is not %NULL, then the operation can be cancelled by
162 	 * triggering the cancellable object from another thread. If the operation
163 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
164 	 *
165 	 * Params:
166 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
167 	 *
168 	 * Returns: a signed 32-bit/4-byte value read from the @stream or %0 if
169 	 *     an error occurred.
170 	 *
171 	 * Throws: GException on failure.
172 	 */
173 	public int readInt32(Cancellable cancellable)
174 	{
175 		GError* err = null;
176 		
177 		auto p = g_data_input_stream_read_int32(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
178 		
179 		if (err !is null)
180 		{
181 			throw new GException( new ErrorG(err) );
182 		}
183 		
184 		return p;
185 	}
186 
187 	/**
188 	 * Reads a 64-bit/8-byte value from @stream.
189 	 *
190 	 * In order to get the correct byte order for this read operation,
191 	 * see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
192 	 *
193 	 * If @cancellable is not %NULL, then the operation can be cancelled by
194 	 * triggering the cancellable object from another thread. If the operation
195 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
196 	 *
197 	 * Params:
198 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
199 	 *
200 	 * Returns: a signed 64-bit/8-byte value read from @stream or %0 if
201 	 *     an error occurred.
202 	 *
203 	 * Throws: GException on failure.
204 	 */
205 	public long readInt64(Cancellable cancellable)
206 	{
207 		GError* err = null;
208 		
209 		auto p = g_data_input_stream_read_int64(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
210 		
211 		if (err !is null)
212 		{
213 			throw new GException( new ErrorG(err) );
214 		}
215 		
216 		return p;
217 	}
218 
219 	/**
220 	 * Reads a line from the data input stream.  Note that no encoding
221 	 * checks or conversion is performed; the input is not guaranteed to
222 	 * be UTF-8, and may in fact have embedded NUL characters.
223 	 *
224 	 * If @cancellable is not %NULL, then the operation can be cancelled by
225 	 * triggering the cancellable object from another thread. If the operation
226 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
227 	 *
228 	 * Params:
229 	 *     length = a #gsize to get the length of the data read in.
230 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
231 	 *
232 	 * Returns: a NUL terminated byte array with the line that was read in
233 	 *     (without the newlines).  Set @length to a #gsize to get the length
234 	 *     of the read line.  On an error, it will return %NULL and @error
235 	 *     will be set. If there's no content to read, it will still return
236 	 *     %NULL, but @error won't be set.
237 	 *
238 	 * Throws: GException on failure.
239 	 */
240 	public string readLine(out size_t length, Cancellable cancellable)
241 	{
242 		GError* err = null;
243 		
244 		auto retStr = g_data_input_stream_read_line(gDataInputStream, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
245 		
246 		if (err !is null)
247 		{
248 			throw new GException( new ErrorG(err) );
249 		}
250 		
251 		scope(exit) Str.freeString(retStr);
252 		return Str.toString(retStr);
253 	}
254 
255 	/**
256 	 * The asynchronous version of g_data_input_stream_read_line().  It is
257 	 * an error to have two outstanding calls to this function.
258 	 *
259 	 * When the operation is finished, @callback will be called. You
260 	 * can then call g_data_input_stream_read_line_finish() to get
261 	 * the result of the operation.
262 	 *
263 	 * Params:
264 	 *     ioPriority = the [I/O priority][io-priority] of the request
265 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
266 	 *     callback = callback to call when the request is satisfied.
267 	 *     userData = the data to pass to callback function.
268 	 *
269 	 * Since: 2.20
270 	 */
271 	public void readLineAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
272 	{
273 		g_data_input_stream_read_line_async(gDataInputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
274 	}
275 
276 	/**
277 	 * Finish an asynchronous call started by
278 	 * g_data_input_stream_read_line_async().  Note the warning about
279 	 * string encoding in g_data_input_stream_read_line() applies here as
280 	 * well.
281 	 *
282 	 * Params:
283 	 *     result = the #GAsyncResult that was provided to the callback.
284 	 *     length = a #gsize to get the length of the data read in.
285 	 *
286 	 * Returns: a NUL-terminated byte array with the line that was read in
287 	 *     (without the newlines).  Set @length to a #gsize to get the length
288 	 *     of the read line.  On an error, it will return %NULL and @error
289 	 *     will be set. If there's no content to read, it will still return
290 	 *     %NULL, but @error won't be set.
291 	 *
292 	 * Since: 2.20
293 	 *
294 	 * Throws: GException on failure.
295 	 */
296 	public string readLineFinish(AsyncResultIF result, out size_t length)
297 	{
298 		GError* err = null;
299 		
300 		auto retStr = g_data_input_stream_read_line_finish(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
301 		
302 		if (err !is null)
303 		{
304 			throw new GException( new ErrorG(err) );
305 		}
306 		
307 		scope(exit) Str.freeString(retStr);
308 		return Str.toString(retStr);
309 	}
310 
311 	/**
312 	 * Finish an asynchronous call started by
313 	 * g_data_input_stream_read_line_async().
314 	 *
315 	 * Params:
316 	 *     result = the #GAsyncResult that was provided to the callback.
317 	 *     length = a #gsize to get the length of the data read in.
318 	 *
319 	 * Returns: a string with the line that
320 	 *     was read in (without the newlines).  Set @length to a #gsize to
321 	 *     get the length of the read line.  On an error, it will return
322 	 *     %NULL and @error will be set. For UTF-8 conversion errors, the set
323 	 *     error domain is %G_CONVERT_ERROR.  If there's no content to read,
324 	 *     it will still return %NULL, but @error won't be set.
325 	 *
326 	 * Since: 2.30
327 	 *
328 	 * Throws: GException on failure.
329 	 */
330 	public string readLineFinishUtf8(AsyncResultIF result, out size_t length)
331 	{
332 		GError* err = null;
333 		
334 		auto retStr = g_data_input_stream_read_line_finish_utf8(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
335 		
336 		if (err !is null)
337 		{
338 			throw new GException( new ErrorG(err) );
339 		}
340 		
341 		scope(exit) Str.freeString(retStr);
342 		return Str.toString(retStr);
343 	}
344 
345 	/**
346 	 * Reads a UTF-8 encoded line from the data input stream.
347 	 *
348 	 * If @cancellable is not %NULL, then the operation can be cancelled by
349 	 * triggering the cancellable object from another thread. If the operation
350 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
351 	 *
352 	 * Params:
353 	 *     length = a #gsize to get the length of the data read in.
354 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
355 	 *
356 	 * Returns: a NUL terminated UTF-8 string
357 	 *     with the line that was read in (without the newlines).  Set
358 	 *     @length to a #gsize to get the length of the read line.  On an
359 	 *     error, it will return %NULL and @error will be set.  For UTF-8
360 	 *     conversion errors, the set error domain is %G_CONVERT_ERROR.  If
361 	 *     there's no content to read, it will still return %NULL, but @error
362 	 *     won't be set.
363 	 *
364 	 * Since: 2.30
365 	 *
366 	 * Throws: GException on failure.
367 	 */
368 	public string readLineUtf8(out size_t length, Cancellable cancellable)
369 	{
370 		GError* err = null;
371 		
372 		auto retStr = g_data_input_stream_read_line_utf8(gDataInputStream, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
373 		
374 		if (err !is null)
375 		{
376 			throw new GException( new ErrorG(err) );
377 		}
378 		
379 		scope(exit) Str.freeString(retStr);
380 		return Str.toString(retStr);
381 	}
382 
383 	/**
384 	 * Reads an unsigned 16-bit/2-byte value from @stream.
385 	 *
386 	 * In order to get the correct byte order for this read operation,
387 	 * see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
388 	 *
389 	 * Params:
390 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
391 	 *
392 	 * Returns: an unsigned 16-bit/2-byte value read from the @stream or %0 if
393 	 *     an error occurred.
394 	 *
395 	 * Throws: GException on failure.
396 	 */
397 	public ushort readUint16(Cancellable cancellable)
398 	{
399 		GError* err = null;
400 		
401 		auto p = g_data_input_stream_read_uint16(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
402 		
403 		if (err !is null)
404 		{
405 			throw new GException( new ErrorG(err) );
406 		}
407 		
408 		return p;
409 	}
410 
411 	/**
412 	 * Reads an unsigned 32-bit/4-byte value from @stream.
413 	 *
414 	 * In order to get the correct byte order for this read operation,
415 	 * see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
416 	 *
417 	 * If @cancellable is not %NULL, then the operation can be cancelled by
418 	 * triggering the cancellable object from another thread. If the operation
419 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
420 	 *
421 	 * Params:
422 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
423 	 *
424 	 * Returns: an unsigned 32-bit/4-byte value read from the @stream or %0 if
425 	 *     an error occurred.
426 	 *
427 	 * Throws: GException on failure.
428 	 */
429 	public uint readUint32(Cancellable cancellable)
430 	{
431 		GError* err = null;
432 		
433 		auto p = g_data_input_stream_read_uint32(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
434 		
435 		if (err !is null)
436 		{
437 			throw new GException( new ErrorG(err) );
438 		}
439 		
440 		return p;
441 	}
442 
443 	/**
444 	 * Reads an unsigned 64-bit/8-byte value from @stream.
445 	 *
446 	 * In order to get the correct byte order for this read operation,
447 	 * see g_data_input_stream_get_byte_order().
448 	 *
449 	 * If @cancellable is not %NULL, then the operation can be cancelled by
450 	 * triggering the cancellable object from another thread. If the operation
451 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
452 	 *
453 	 * Params:
454 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
455 	 *
456 	 * Returns: an unsigned 64-bit/8-byte read from @stream or %0 if
457 	 *     an error occurred.
458 	 *
459 	 * Throws: GException on failure.
460 	 */
461 	public ulong readUint64(Cancellable cancellable)
462 	{
463 		GError* err = null;
464 		
465 		auto p = g_data_input_stream_read_uint64(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
466 		
467 		if (err !is null)
468 		{
469 			throw new GException( new ErrorG(err) );
470 		}
471 		
472 		return p;
473 	}
474 
475 	/**
476 	 * Reads a string from the data input stream, up to the first
477 	 * occurrence of any of the stop characters.
478 	 *
479 	 * Note that, in contrast to g_data_input_stream_read_until_async(),
480 	 * this function consumes the stop character that it finds.
481 	 *
482 	 * Don't use this function in new code.  Its functionality is
483 	 * inconsistent with g_data_input_stream_read_until_async().  Both
484 	 * functions will be marked as deprecated in a future release.  Use
485 	 * g_data_input_stream_read_upto() instead, but note that that function
486 	 * does not consume the stop character.
487 	 *
488 	 * Params:
489 	 *     stopChars = characters to terminate the read.
490 	 *     length = a #gsize to get the length of the data read in.
491 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
492 	 *
493 	 * Returns: a string with the data that was read
494 	 *     before encountering any of the stop characters. Set @length to
495 	 *     a #gsize to get the length of the string. This function will
496 	 *     return %NULL on an error.
497 	 *
498 	 * Throws: GException on failure.
499 	 */
500 	public string readUntil(string stopChars, out size_t length, Cancellable cancellable)
501 	{
502 		GError* err = null;
503 		
504 		auto retStr = g_data_input_stream_read_until(gDataInputStream, Str.toStringz(stopChars), &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
505 		
506 		if (err !is null)
507 		{
508 			throw new GException( new ErrorG(err) );
509 		}
510 		
511 		scope(exit) Str.freeString(retStr);
512 		return Str.toString(retStr);
513 	}
514 
515 	/**
516 	 * The asynchronous version of g_data_input_stream_read_until().
517 	 * It is an error to have two outstanding calls to this function.
518 	 *
519 	 * Note that, in contrast to g_data_input_stream_read_until(),
520 	 * this function does not consume the stop character that it finds.  You
521 	 * must read it for yourself.
522 	 *
523 	 * When the operation is finished, @callback will be called. You
524 	 * can then call g_data_input_stream_read_until_finish() to get
525 	 * the result of the operation.
526 	 *
527 	 * Don't use this function in new code.  Its functionality is
528 	 * inconsistent with g_data_input_stream_read_until().  Both functions
529 	 * will be marked as deprecated in a future release.  Use
530 	 * g_data_input_stream_read_upto_async() instead.
531 	 *
532 	 * Params:
533 	 *     stopChars = characters to terminate the read.
534 	 *     ioPriority = the [I/O priority][io-priority] of the request
535 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
536 	 *     callback = callback to call when the request is satisfied.
537 	 *     userData = the data to pass to callback function.
538 	 *
539 	 * Since: 2.20
540 	 */
541 	public void readUntilAsync(string stopChars, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
542 	{
543 		g_data_input_stream_read_until_async(gDataInputStream, Str.toStringz(stopChars), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
544 	}
545 
546 	/**
547 	 * Finish an asynchronous call started by
548 	 * g_data_input_stream_read_until_async().
549 	 *
550 	 * Params:
551 	 *     result = the #GAsyncResult that was provided to the callback.
552 	 *     length = a #gsize to get the length of the data read in.
553 	 *
554 	 * Returns: a string with the data that was read
555 	 *     before encountering any of the stop characters. Set @length to
556 	 *     a #gsize to get the length of the string. This function will
557 	 *     return %NULL on an error.
558 	 *
559 	 * Since: 2.20
560 	 *
561 	 * Throws: GException on failure.
562 	 */
563 	public string readUntilFinish(AsyncResultIF result, out size_t length)
564 	{
565 		GError* err = null;
566 		
567 		auto retStr = g_data_input_stream_read_until_finish(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
568 		
569 		if (err !is null)
570 		{
571 			throw new GException( new ErrorG(err) );
572 		}
573 		
574 		scope(exit) Str.freeString(retStr);
575 		return Str.toString(retStr);
576 	}
577 
578 	/**
579 	 * Reads a string from the data input stream, up to the first
580 	 * occurrence of any of the stop characters.
581 	 *
582 	 * In contrast to g_data_input_stream_read_until(), this function
583 	 * does not consume the stop character. You have to use
584 	 * g_data_input_stream_read_byte() to get it before calling
585 	 * g_data_input_stream_read_upto() again.
586 	 *
587 	 * Note that @stop_chars may contain '\0' if @stop_chars_len is
588 	 * specified.
589 	 *
590 	 * Params:
591 	 *     stopChars = characters to terminate the read
592 	 *     stopCharsLen = length of @stop_chars. May be -1 if @stop_chars is
593 	 *         nul-terminated
594 	 *     length = a #gsize to get the length of the data read in
595 	 *     cancellable = optional #GCancellable object, %NULL to ignore
596 	 *
597 	 * Returns: a string with the data that was read
598 	 *     before encountering any of the stop characters. Set @length to
599 	 *     a #gsize to get the length of the string. This function will
600 	 *     return %NULL on an error
601 	 *
602 	 * Since: 2.26
603 	 *
604 	 * Throws: GException on failure.
605 	 */
606 	public string readUpto(string stopChars, ptrdiff_t stopCharsLen, out size_t length, Cancellable cancellable)
607 	{
608 		GError* err = null;
609 		
610 		auto retStr = g_data_input_stream_read_upto(gDataInputStream, Str.toStringz(stopChars), stopCharsLen, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
611 		
612 		if (err !is null)
613 		{
614 			throw new GException( new ErrorG(err) );
615 		}
616 		
617 		scope(exit) Str.freeString(retStr);
618 		return Str.toString(retStr);
619 	}
620 
621 	/**
622 	 * The asynchronous version of g_data_input_stream_read_upto().
623 	 * It is an error to have two outstanding calls to this function.
624 	 *
625 	 * In contrast to g_data_input_stream_read_until(), this function
626 	 * does not consume the stop character. You have to use
627 	 * g_data_input_stream_read_byte() to get it before calling
628 	 * g_data_input_stream_read_upto() again.
629 	 *
630 	 * Note that @stop_chars may contain '\0' if @stop_chars_len is
631 	 * specified.
632 	 *
633 	 * When the operation is finished, @callback will be called. You
634 	 * can then call g_data_input_stream_read_upto_finish() to get
635 	 * the result of the operation.
636 	 *
637 	 * Params:
638 	 *     stopChars = characters to terminate the read
639 	 *     stopCharsLen = length of @stop_chars. May be -1 if @stop_chars is
640 	 *         nul-terminated
641 	 *     ioPriority = the [I/O priority][io-priority] of the request
642 	 *     cancellable = optional #GCancellable object, %NULL to ignore
643 	 *     callback = callback to call when the request is satisfied
644 	 *     userData = the data to pass to callback function
645 	 *
646 	 * Since: 2.26
647 	 */
648 	public void readUptoAsync(string stopChars, ptrdiff_t stopCharsLen, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
649 	{
650 		g_data_input_stream_read_upto_async(gDataInputStream, Str.toStringz(stopChars), stopCharsLen, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
651 	}
652 
653 	/**
654 	 * Finish an asynchronous call started by
655 	 * g_data_input_stream_read_upto_async().
656 	 *
657 	 * Note that this function does not consume the stop character. You
658 	 * have to use g_data_input_stream_read_byte() to get it before calling
659 	 * g_data_input_stream_read_upto_async() again.
660 	 *
661 	 * Params:
662 	 *     result = the #GAsyncResult that was provided to the callback
663 	 *     length = a #gsize to get the length of the data read in
664 	 *
665 	 * Returns: a string with the data that was read
666 	 *     before encountering any of the stop characters. Set @length to
667 	 *     a #gsize to get the length of the string. This function will
668 	 *     return %NULL on an error.
669 	 *
670 	 * Since: 2.24
671 	 *
672 	 * Throws: GException on failure.
673 	 */
674 	public string readUptoFinish(AsyncResultIF result, out size_t length)
675 	{
676 		GError* err = null;
677 		
678 		auto retStr = g_data_input_stream_read_upto_finish(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
679 		
680 		if (err !is null)
681 		{
682 			throw new GException( new ErrorG(err) );
683 		}
684 		
685 		scope(exit) Str.freeString(retStr);
686 		return Str.toString(retStr);
687 	}
688 
689 	/**
690 	 * This function sets the byte order for the given @stream. All subsequent
691 	 * reads from the @stream will be read in the given @order.
692 	 *
693 	 * Params:
694 	 *     order = a #GDataStreamByteOrder to set.
695 	 */
696 	public void setByteOrder(GDataStreamByteOrder order)
697 	{
698 		g_data_input_stream_set_byte_order(gDataInputStream, order);
699 	}
700 
701 	/**
702 	 * Sets the newline type for the @stream.
703 	 *
704 	 * Note that using G_DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a read
705 	 * chunk ends in "CR" we must read an additional byte to know if this is "CR" or
706 	 * "CR LF", and this might block if there is no more data available.
707 	 *
708 	 * Params:
709 	 *     type = the type of new line return as #GDataStreamNewlineType.
710 	 */
711 	public void setNewlineType(GDataStreamNewlineType type)
712 	{
713 		g_data_input_stream_set_newline_type(gDataInputStream, type);
714 	}
715 }