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