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