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 gst.base.ByteReader;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gst.base.c.functions;
31 public  import gst.base.c.types;
32 private import gtkd.Loader;
33 
34 
35 /**
36  * #GstByteReader provides a byte reader that can read different integer and
37  * floating point types from a memory buffer. It provides functions for reading
38  * signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits
39  * and functions for reading little/big endian floating points numbers of
40  * 32 and 64 bits. It also provides functions to read NUL-terminated strings
41  * in various character encodings.
42  */
43 public class ByteReader
44 {
45 	/** the main Gtk struct */
46 	protected GstByteReader* gstByteReader;
47 	protected bool ownedRef;
48 
49 	/** Get the main Gtk struct */
50 	public GstByteReader* getByteReaderStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gstByteReader;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected void* getStruct()
59 	{
60 		return cast(void*)gstByteReader;
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GstByteReader* gstByteReader, bool ownedRef = false)
67 	{
68 		this.gstByteReader = gstByteReader;
69 		this.ownedRef = ownedRef;
70 	}
71 
72 	~this ()
73 	{
74 		if ( Linker.isLoaded(LIBRARY_GSTBASE) && ownedRef )
75 			gst_byte_reader_free(gstByteReader);
76 	}
77 
78 
79 	/**
80 	 * Free-function: g_free
81 	 *
82 	 * Returns a newly-allocated copy of the current data
83 	 * position if at least @size bytes are left and
84 	 * updates the current position. Free with g_free() when no longer needed.
85 	 *
86 	 * Params:
87 	 *     val = address of a
88 	 *         #guint8 pointer variable in which to store the result
89 	 *
90 	 * Returns: %TRUE if successful, %FALSE otherwise.
91 	 */
92 	public bool dupData(out ubyte[] val)
93 	{
94 		ubyte* outval = null;
95 
96 		auto p = gst_byte_reader_dup_data(gstByteReader, cast(uint)val.length, &outval) != 0;
97 
98 		val = outval[0 .. cast(uint)val.length];
99 
100 		return p;
101 	}
102 
103 	/**
104 	 * Free-function: g_free
105 	 *
106 	 * Returns a newly-allocated copy of the current data position if there is
107 	 * a NUL-terminated UTF-16 string in the data (this could be an empty string
108 	 * as well), and advances the current position.
109 	 *
110 	 * No input checking for valid UTF-16 is done. This function is endianness
111 	 * agnostic - you should not assume the UTF-16 characters are in host
112 	 * endianness.
113 	 *
114 	 * This function will fail if no NUL-terminator was found in in the data.
115 	 *
116 	 * Note: there is no peek or get variant of this function to ensure correct
117 	 * byte alignment of the UTF-16 string.
118 	 *
119 	 * Params:
120 	 *     str = address of a
121 	 *         #guint16 pointer variable in which to store the result
122 	 *
123 	 * Returns: %TRUE if a string could be read, %FALSE otherwise. The
124 	 *     string put into @str must be freed with g_free() when no longer needed.
125 	 */
126 	public bool dupStringUtf16(out ushort[] str)
127 	{
128 		ushort* outstr = null;
129 
130 		auto p = gst_byte_reader_dup_string_utf16(gstByteReader, &outstr) != 0;
131 
132 		str = outstr[0 .. getArrayLength(outstr)];
133 
134 		return p;
135 	}
136 
137 	/**
138 	 * Free-function: g_free
139 	 *
140 	 * Returns a newly-allocated copy of the current data position if there is
141 	 * a NUL-terminated UTF-32 string in the data (this could be an empty string
142 	 * as well), and advances the current position.
143 	 *
144 	 * No input checking for valid UTF-32 is done. This function is endianness
145 	 * agnostic - you should not assume the UTF-32 characters are in host
146 	 * endianness.
147 	 *
148 	 * This function will fail if no NUL-terminator was found in in the data.
149 	 *
150 	 * Note: there is no peek or get variant of this function to ensure correct
151 	 * byte alignment of the UTF-32 string.
152 	 *
153 	 * Params:
154 	 *     str = address of a
155 	 *         #guint32 pointer variable in which to store the result
156 	 *
157 	 * Returns: %TRUE if a string could be read, %FALSE otherwise. The
158 	 *     string put into @str must be freed with g_free() when no longer needed.
159 	 */
160 	public bool dupStringUtf32(out uint[] str)
161 	{
162 		uint* outstr = null;
163 
164 		auto p = gst_byte_reader_dup_string_utf32(gstByteReader, &outstr) != 0;
165 
166 		str = outstr[0 .. getArrayLength(outstr)];
167 
168 		return p;
169 	}
170 
171 	/**
172 	 * Free-function: g_free
173 	 *
174 	 * FIXME:Reads (copies) a NUL-terminated string in the #GstByteReader instance,
175 	 * advancing the current position to the byte after the string. This will work
176 	 * for any NUL-terminated string with a character width of 8 bits, so ASCII,
177 	 * UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.
178 	 *
179 	 * This function will fail if no NUL-terminator was found in in the data.
180 	 *
181 	 * Params:
182 	 *     str = address of a
183 	 *         #gchar pointer variable in which to store the result
184 	 *
185 	 * Returns: %TRUE if a string could be read into @str, %FALSE otherwise. The
186 	 *     string put into @str must be freed with g_free() when no longer needed.
187 	 */
188 	public bool dupStringUtf8(out string str)
189 	{
190 		char* outstr = null;
191 
192 		auto p = gst_byte_reader_dup_string_utf8(gstByteReader, &outstr) != 0;
193 
194 		str = Str.toString(outstr);
195 
196 		return p;
197 	}
198 
199 	/**
200 	 * Frees a #GstByteReader instance, which was previously allocated by
201 	 * gst_byte_reader_new().
202 	 */
203 	public void free()
204 	{
205 		gst_byte_reader_free(gstByteReader);
206 		ownedRef = false;
207 	}
208 
209 	/**
210 	 * Returns a constant pointer to the current data
211 	 * position if at least @size bytes are left and
212 	 * updates the current position.
213 	 *
214 	 * Params:
215 	 *     val = address of a
216 	 *         #guint8 pointer variable in which to store the result
217 	 *
218 	 * Returns: %TRUE if successful, %FALSE otherwise.
219 	 */
220 	public bool getData(out ubyte[] val)
221 	{
222 		ubyte* outval = null;
223 
224 		auto p = gst_byte_reader_get_data(gstByteReader, cast(uint)val.length, &outval) != 0;
225 
226 		val = outval[0 .. cast(uint)val.length];
227 
228 		return p;
229 	}
230 
231 	/**
232 	 * Read a 32 bit big endian floating point value into @val
233 	 * and update the current position.
234 	 *
235 	 * Params:
236 	 *     val = Pointer to a #gfloat to store the result
237 	 *
238 	 * Returns: %TRUE if successful, %FALSE otherwise.
239 	 */
240 	public bool getFloat32Be(out float val)
241 	{
242 		return gst_byte_reader_get_float32_be(gstByteReader, &val) != 0;
243 	}
244 
245 	/**
246 	 * Read a 32 bit little endian floating point value into @val
247 	 * and update the current position.
248 	 *
249 	 * Params:
250 	 *     val = Pointer to a #gfloat to store the result
251 	 *
252 	 * Returns: %TRUE if successful, %FALSE otherwise.
253 	 */
254 	public bool getFloat32Le(out float val)
255 	{
256 		return gst_byte_reader_get_float32_le(gstByteReader, &val) != 0;
257 	}
258 
259 	/**
260 	 * Read a 64 bit big endian floating point value into @val
261 	 * and update the current position.
262 	 *
263 	 * Params:
264 	 *     val = Pointer to a #gdouble to store the result
265 	 *
266 	 * Returns: %TRUE if successful, %FALSE otherwise.
267 	 */
268 	public bool getFloat64Be(out double val)
269 	{
270 		return gst_byte_reader_get_float64_be(gstByteReader, &val) != 0;
271 	}
272 
273 	/**
274 	 * Read a 64 bit little endian floating point value into @val
275 	 * and update the current position.
276 	 *
277 	 * Params:
278 	 *     val = Pointer to a #gdouble to store the result
279 	 *
280 	 * Returns: %TRUE if successful, %FALSE otherwise.
281 	 */
282 	public bool getFloat64Le(out double val)
283 	{
284 		return gst_byte_reader_get_float64_le(gstByteReader, &val) != 0;
285 	}
286 
287 	/**
288 	 * Read a signed 16 bit big endian integer into @val
289 	 * and update the current position.
290 	 *
291 	 * Params:
292 	 *     val = Pointer to a #gint16 to store the result
293 	 *
294 	 * Returns: %TRUE if successful, %FALSE otherwise.
295 	 */
296 	public bool getInt16Be(out short val)
297 	{
298 		return gst_byte_reader_get_int16_be(gstByteReader, &val) != 0;
299 	}
300 
301 	/**
302 	 * Read a signed 16 bit little endian integer into @val
303 	 * and update the current position.
304 	 *
305 	 * Params:
306 	 *     val = Pointer to a #gint16 to store the result
307 	 *
308 	 * Returns: %TRUE if successful, %FALSE otherwise.
309 	 */
310 	public bool getInt16Le(out short val)
311 	{
312 		return gst_byte_reader_get_int16_le(gstByteReader, &val) != 0;
313 	}
314 
315 	/**
316 	 * Read a signed 24 bit big endian integer into @val
317 	 * and update the current position.
318 	 *
319 	 * Params:
320 	 *     val = Pointer to a #gint32 to store the result
321 	 *
322 	 * Returns: %TRUE if successful, %FALSE otherwise.
323 	 */
324 	public bool getInt24Be(out int val)
325 	{
326 		return gst_byte_reader_get_int24_be(gstByteReader, &val) != 0;
327 	}
328 
329 	/**
330 	 * Read a signed 24 bit little endian integer into @val
331 	 * and update the current position.
332 	 *
333 	 * Params:
334 	 *     val = Pointer to a #gint32 to store the result
335 	 *
336 	 * Returns: %TRUE if successful, %FALSE otherwise.
337 	 */
338 	public bool getInt24Le(out int val)
339 	{
340 		return gst_byte_reader_get_int24_le(gstByteReader, &val) != 0;
341 	}
342 
343 	/**
344 	 * Read a signed 32 bit big endian integer into @val
345 	 * and update the current position.
346 	 *
347 	 * Params:
348 	 *     val = Pointer to a #gint32 to store the result
349 	 *
350 	 * Returns: %TRUE if successful, %FALSE otherwise.
351 	 */
352 	public bool getInt32Be(out int val)
353 	{
354 		return gst_byte_reader_get_int32_be(gstByteReader, &val) != 0;
355 	}
356 
357 	/**
358 	 * Read a signed 32 bit little endian integer into @val
359 	 * and update the current position.
360 	 *
361 	 * Params:
362 	 *     val = Pointer to a #gint32 to store the result
363 	 *
364 	 * Returns: %TRUE if successful, %FALSE otherwise.
365 	 */
366 	public bool getInt32Le(out int val)
367 	{
368 		return gst_byte_reader_get_int32_le(gstByteReader, &val) != 0;
369 	}
370 
371 	/**
372 	 * Read a signed 64 bit big endian integer into @val
373 	 * and update the current position.
374 	 *
375 	 * Params:
376 	 *     val = Pointer to a #gint64 to store the result
377 	 *
378 	 * Returns: %TRUE if successful, %FALSE otherwise.
379 	 */
380 	public bool getInt64Be(out long val)
381 	{
382 		return gst_byte_reader_get_int64_be(gstByteReader, &val) != 0;
383 	}
384 
385 	/**
386 	 * Read a signed 64 bit little endian integer into @val
387 	 * and update the current position.
388 	 *
389 	 * Params:
390 	 *     val = Pointer to a #gint64 to store the result
391 	 *
392 	 * Returns: %TRUE if successful, %FALSE otherwise.
393 	 */
394 	public bool getInt64Le(out long val)
395 	{
396 		return gst_byte_reader_get_int64_le(gstByteReader, &val) != 0;
397 	}
398 
399 	/**
400 	 * Read a signed 8 bit integer into @val and update the current position.
401 	 *
402 	 * Params:
403 	 *     val = Pointer to a #gint8 to store the result
404 	 *
405 	 * Returns: %TRUE if successful, %FALSE otherwise.
406 	 */
407 	public bool getInt8(out byte val)
408 	{
409 		return gst_byte_reader_get_int8(gstByteReader, &val) != 0;
410 	}
411 
412 	/**
413 	 * Returns the current position of a #GstByteReader instance in bytes.
414 	 *
415 	 * Returns: The current position of @reader in bytes.
416 	 */
417 	public uint getPos()
418 	{
419 		return gst_byte_reader_get_pos(gstByteReader);
420 	}
421 
422 	/**
423 	 * Returns the remaining number of bytes of a #GstByteReader instance.
424 	 *
425 	 * Returns: The remaining number of bytes of @reader instance.
426 	 */
427 	public uint getRemaining()
428 	{
429 		return gst_byte_reader_get_remaining(gstByteReader);
430 	}
431 
432 	/**
433 	 * Returns the total number of bytes of a #GstByteReader instance.
434 	 *
435 	 * Returns: The total number of bytes of @reader instance.
436 	 */
437 	public uint getSize()
438 	{
439 		return gst_byte_reader_get_size(gstByteReader);
440 	}
441 
442 	/**
443 	 * Returns a constant pointer to the current data position if there is
444 	 * a NUL-terminated string in the data (this could be just a NUL terminator),
445 	 * advancing the current position to the byte after the string. This will work
446 	 * for any NUL-terminated string with a character width of 8 bits, so ASCII,
447 	 * UTF-8, ISO-8859-N etc.
448 	 *
449 	 * No input checking for valid UTF-8 is done.
450 	 *
451 	 * This function will fail if no NUL-terminator was found in in the data.
452 	 *
453 	 * Params:
454 	 *     str = address of a
455 	 *         #gchar pointer variable in which to store the result
456 	 *
457 	 * Returns: %TRUE if a string could be found, %FALSE otherwise.
458 	 */
459 	public bool getStringUtf8(out string str)
460 	{
461 		char* outstr = null;
462 
463 		auto p = gst_byte_reader_get_string_utf8(gstByteReader, &outstr) != 0;
464 
465 		str = Str.toString(outstr);
466 
467 		return p;
468 	}
469 
470 	/**
471 	 * Initializes a #GstByteReader sub-reader instance to contain @size bytes of
472 	 * data from the current position of @reader. This is useful to read chunked
473 	 * formats and make sure that one doesn't read beyond the size of the sub-chunk.
474 	 *
475 	 * Unlike gst_byte_reader_peek_sub_reader(), this function also modifies the
476 	 * position of @reader and moves it forward by @size bytes.
477 	 *
478 	 * Params:
479 	 *     subReader = a #GstByteReader instance to initialize as sub-reader
480 	 *     size = size of @sub_reader in bytes
481 	 *
482 	 * Returns: FALSE on error or if @reader does not contain @size more bytes from
483 	 *     the current position, and otherwise TRUE
484 	 *
485 	 * Since: 1.6
486 	 */
487 	public bool getSubReader(ByteReader subReader, uint size)
488 	{
489 		return gst_byte_reader_get_sub_reader(gstByteReader, (subReader is null) ? null : subReader.getByteReaderStruct(), size) != 0;
490 	}
491 
492 	/**
493 	 * Read an unsigned 16 bit big endian integer into @val
494 	 * and update the current position.
495 	 *
496 	 * Params:
497 	 *     val = Pointer to a #guint16 to store the result
498 	 *
499 	 * Returns: %TRUE if successful, %FALSE otherwise.
500 	 */
501 	public bool getUint16Be(out ushort val)
502 	{
503 		return gst_byte_reader_get_uint16_be(gstByteReader, &val) != 0;
504 	}
505 
506 	/**
507 	 * Read an unsigned 16 bit little endian integer into @val
508 	 * and update the current position.
509 	 *
510 	 * Params:
511 	 *     val = Pointer to a #guint16 to store the result
512 	 *
513 	 * Returns: %TRUE if successful, %FALSE otherwise.
514 	 */
515 	public bool getUint16Le(out ushort val)
516 	{
517 		return gst_byte_reader_get_uint16_le(gstByteReader, &val) != 0;
518 	}
519 
520 	/**
521 	 * Read an unsigned 24 bit big endian integer into @val
522 	 * and update the current position.
523 	 *
524 	 * Params:
525 	 *     val = Pointer to a #guint32 to store the result
526 	 *
527 	 * Returns: %TRUE if successful, %FALSE otherwise.
528 	 */
529 	public bool getUint24Be(out uint val)
530 	{
531 		return gst_byte_reader_get_uint24_be(gstByteReader, &val) != 0;
532 	}
533 
534 	/**
535 	 * Read an unsigned 24 bit little endian integer into @val
536 	 * and update the current position.
537 	 *
538 	 * Params:
539 	 *     val = Pointer to a #guint32 to store the result
540 	 *
541 	 * Returns: %TRUE if successful, %FALSE otherwise.
542 	 */
543 	public bool getUint24Le(out uint val)
544 	{
545 		return gst_byte_reader_get_uint24_le(gstByteReader, &val) != 0;
546 	}
547 
548 	/**
549 	 * Read an unsigned 32 bit big endian integer into @val
550 	 * and update the current position.
551 	 *
552 	 * Params:
553 	 *     val = Pointer to a #guint32 to store the result
554 	 *
555 	 * Returns: %TRUE if successful, %FALSE otherwise.
556 	 */
557 	public bool getUint32Be(out uint val)
558 	{
559 		return gst_byte_reader_get_uint32_be(gstByteReader, &val) != 0;
560 	}
561 
562 	/**
563 	 * Read an unsigned 32 bit little endian integer into @val
564 	 * and update the current position.
565 	 *
566 	 * Params:
567 	 *     val = Pointer to a #guint32 to store the result
568 	 *
569 	 * Returns: %TRUE if successful, %FALSE otherwise.
570 	 */
571 	public bool getUint32Le(out uint val)
572 	{
573 		return gst_byte_reader_get_uint32_le(gstByteReader, &val) != 0;
574 	}
575 
576 	/**
577 	 * Read an unsigned 64 bit big endian integer into @val
578 	 * and update the current position.
579 	 *
580 	 * Params:
581 	 *     val = Pointer to a #guint64 to store the result
582 	 *
583 	 * Returns: %TRUE if successful, %FALSE otherwise.
584 	 */
585 	public bool getUint64Be(out ulong val)
586 	{
587 		return gst_byte_reader_get_uint64_be(gstByteReader, &val) != 0;
588 	}
589 
590 	/**
591 	 * Read an unsigned 64 bit little endian integer into @val
592 	 * and update the current position.
593 	 *
594 	 * Params:
595 	 *     val = Pointer to a #guint64 to store the result
596 	 *
597 	 * Returns: %TRUE if successful, %FALSE otherwise.
598 	 */
599 	public bool getUint64Le(out ulong val)
600 	{
601 		return gst_byte_reader_get_uint64_le(gstByteReader, &val) != 0;
602 	}
603 
604 	/**
605 	 * Read an unsigned 8 bit integer into @val and update the current position.
606 	 *
607 	 * Params:
608 	 *     val = Pointer to a #guint8 to store the result
609 	 *
610 	 * Returns: %TRUE if successful, %FALSE otherwise.
611 	 */
612 	public bool getUint8(out ubyte val)
613 	{
614 		return gst_byte_reader_get_uint8(gstByteReader, &val) != 0;
615 	}
616 
617 	/**
618 	 * Initializes a #GstByteReader instance to read from @data. This function
619 	 * can be called on already initialized instances.
620 	 *
621 	 * Params:
622 	 *     data = data from which
623 	 *         the #GstByteReader should read
624 	 */
625 	public void init(ubyte[] data)
626 	{
627 		gst_byte_reader_init(gstByteReader, data.ptr, cast(uint)data.length);
628 	}
629 
630 	/**
631 	 * Scan for pattern @pattern with applied mask @mask in the byte reader data,
632 	 * starting from offset @offset relative to the current position.
633 	 *
634 	 * The bytes in @pattern and @mask are interpreted left-to-right, regardless
635 	 * of endianness.  All four bytes of the pattern must be present in the
636 	 * byte reader data for it to match, even if the first or last bytes are masked
637 	 * out.
638 	 *
639 	 * It is an error to call this function without making sure that there is
640 	 * enough data (offset+size bytes) in the byte reader.
641 	 *
642 	 * Params:
643 	 *     mask = mask to apply to data before matching against @pattern
644 	 *     pattern = pattern to match (after mask is applied)
645 	 *     offset = offset from which to start scanning, relative to the current
646 	 *         position
647 	 *     size = number of bytes to scan from offset
648 	 *
649 	 * Returns: offset of the first match, or -1 if no match was found.
650 	 *
651 	 *     Example:
652 	 *     |[
653 	 *     // Assume the reader contains 0x00 0x01 0x02 ... 0xfe 0xff
654 	 *
655 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 0, 256);
656 	 *     // -> returns 0
657 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 1, 255);
658 	 *     // -> returns -1
659 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x01020304, 1, 255);
660 	 *     // -> returns 1
661 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0001, 0, 256);
662 	 *     // -> returns -1
663 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0203, 0, 256);
664 	 *     // -> returns 0
665 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 256);
666 	 *     // -> returns 2
667 	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 4);
668 	 *     // -> returns -1
669 	 *     ]|
670 	 */
671 	public uint maskedScanUint32(uint mask, uint pattern, uint offset, uint size)
672 	{
673 		return gst_byte_reader_masked_scan_uint32(gstByteReader, mask, pattern, offset, size);
674 	}
675 
676 	/**
677 	 * Scan for pattern @pattern with applied mask @mask in the byte reader data,
678 	 * starting from offset @offset relative to the current position.
679 	 *
680 	 * The bytes in @pattern and @mask are interpreted left-to-right, regardless
681 	 * of endianness.  All four bytes of the pattern must be present in the
682 	 * byte reader data for it to match, even if the first or last bytes are masked
683 	 * out.
684 	 *
685 	 * It is an error to call this function without making sure that there is
686 	 * enough data (offset+size bytes) in the byte reader.
687 	 *
688 	 * Params:
689 	 *     mask = mask to apply to data before matching against @pattern
690 	 *     pattern = pattern to match (after mask is applied)
691 	 *     offset = offset from which to start scanning, relative to the current
692 	 *         position
693 	 *     size = number of bytes to scan from offset
694 	 *     value = pointer to uint32 to return matching data
695 	 *
696 	 * Returns: offset of the first match, or -1 if no match was found.
697 	 *
698 	 * Since: 1.6
699 	 */
700 	public uint maskedScanUint32Peek(uint mask, uint pattern, uint offset, uint size, out uint value)
701 	{
702 		return gst_byte_reader_masked_scan_uint32_peek(gstByteReader, mask, pattern, offset, size, &value);
703 	}
704 
705 	/**
706 	 * Returns a constant pointer to the current data
707 	 * position if at least @size bytes are left and
708 	 * keeps the current position.
709 	 *
710 	 * Params:
711 	 *     val = address of a
712 	 *         #guint8 pointer variable in which to store the result
713 	 *
714 	 * Returns: %TRUE if successful, %FALSE otherwise.
715 	 */
716 	public bool peekData(out ubyte[] val)
717 	{
718 		ubyte* outval = null;
719 
720 		auto p = gst_byte_reader_peek_data(gstByteReader, cast(uint)val.length, &outval) != 0;
721 
722 		val = outval[0 .. cast(uint)val.length];
723 
724 		return p;
725 	}
726 
727 	/**
728 	 * Read a 32 bit big endian floating point value into @val
729 	 * but keep the current position.
730 	 *
731 	 * Params:
732 	 *     val = Pointer to a #gfloat to store the result
733 	 *
734 	 * Returns: %TRUE if successful, %FALSE otherwise.
735 	 */
736 	public bool peekFloat32Be(out float val)
737 	{
738 		return gst_byte_reader_peek_float32_be(gstByteReader, &val) != 0;
739 	}
740 
741 	/**
742 	 * Read a 32 bit little endian floating point value into @val
743 	 * but keep the current position.
744 	 *
745 	 * Params:
746 	 *     val = Pointer to a #gfloat to store the result
747 	 *
748 	 * Returns: %TRUE if successful, %FALSE otherwise.
749 	 */
750 	public bool peekFloat32Le(out float val)
751 	{
752 		return gst_byte_reader_peek_float32_le(gstByteReader, &val) != 0;
753 	}
754 
755 	/**
756 	 * Read a 64 bit big endian floating point value into @val
757 	 * but keep the current position.
758 	 *
759 	 * Params:
760 	 *     val = Pointer to a #gdouble to store the result
761 	 *
762 	 * Returns: %TRUE if successful, %FALSE otherwise.
763 	 */
764 	public bool peekFloat64Be(out double val)
765 	{
766 		return gst_byte_reader_peek_float64_be(gstByteReader, &val) != 0;
767 	}
768 
769 	/**
770 	 * Read a 64 bit little endian floating point value into @val
771 	 * but keep the current position.
772 	 *
773 	 * Params:
774 	 *     val = Pointer to a #gdouble to store the result
775 	 *
776 	 * Returns: %TRUE if successful, %FALSE otherwise.
777 	 */
778 	public bool peekFloat64Le(out double val)
779 	{
780 		return gst_byte_reader_peek_float64_le(gstByteReader, &val) != 0;
781 	}
782 
783 	/**
784 	 * Read a signed 16 bit big endian integer into @val
785 	 * but keep the current position.
786 	 *
787 	 * Params:
788 	 *     val = Pointer to a #gint16 to store the result
789 	 *
790 	 * Returns: %TRUE if successful, %FALSE otherwise.
791 	 */
792 	public bool peekInt16Be(out short val)
793 	{
794 		return gst_byte_reader_peek_int16_be(gstByteReader, &val) != 0;
795 	}
796 
797 	/**
798 	 * Read a signed 16 bit little endian integer into @val
799 	 * but keep the current position.
800 	 *
801 	 * Params:
802 	 *     val = Pointer to a #gint16 to store the result
803 	 *
804 	 * Returns: %TRUE if successful, %FALSE otherwise.
805 	 */
806 	public bool peekInt16Le(out short val)
807 	{
808 		return gst_byte_reader_peek_int16_le(gstByteReader, &val) != 0;
809 	}
810 
811 	/**
812 	 * Read a signed 24 bit big endian integer into @val
813 	 * but keep the current position.
814 	 *
815 	 * Params:
816 	 *     val = Pointer to a #gint32 to store the result
817 	 *
818 	 * Returns: %TRUE if successful, %FALSE otherwise.
819 	 */
820 	public bool peekInt24Be(out int val)
821 	{
822 		return gst_byte_reader_peek_int24_be(gstByteReader, &val) != 0;
823 	}
824 
825 	/**
826 	 * Read a signed 24 bit little endian integer into @val
827 	 * but keep the current position.
828 	 *
829 	 * Params:
830 	 *     val = Pointer to a #gint32 to store the result
831 	 *
832 	 * Returns: %TRUE if successful, %FALSE otherwise.
833 	 */
834 	public bool peekInt24Le(out int val)
835 	{
836 		return gst_byte_reader_peek_int24_le(gstByteReader, &val) != 0;
837 	}
838 
839 	/**
840 	 * Read a signed 32 bit big endian integer into @val
841 	 * but keep the current position.
842 	 *
843 	 * Params:
844 	 *     val = Pointer to a #gint32 to store the result
845 	 *
846 	 * Returns: %TRUE if successful, %FALSE otherwise.
847 	 */
848 	public bool peekInt32Be(out int val)
849 	{
850 		return gst_byte_reader_peek_int32_be(gstByteReader, &val) != 0;
851 	}
852 
853 	/**
854 	 * Read a signed 32 bit little endian integer into @val
855 	 * but keep the current position.
856 	 *
857 	 * Params:
858 	 *     val = Pointer to a #gint32 to store the result
859 	 *
860 	 * Returns: %TRUE if successful, %FALSE otherwise.
861 	 */
862 	public bool peekInt32Le(out int val)
863 	{
864 		return gst_byte_reader_peek_int32_le(gstByteReader, &val) != 0;
865 	}
866 
867 	/**
868 	 * Read a signed 64 bit big endian integer into @val
869 	 * but keep the current position.
870 	 *
871 	 * Params:
872 	 *     val = Pointer to a #gint64 to store the result
873 	 *
874 	 * Returns: %TRUE if successful, %FALSE otherwise.
875 	 */
876 	public bool peekInt64Be(out long val)
877 	{
878 		return gst_byte_reader_peek_int64_be(gstByteReader, &val) != 0;
879 	}
880 
881 	/**
882 	 * Read a signed 64 bit little endian integer into @val
883 	 * but keep the current position.
884 	 *
885 	 * Params:
886 	 *     val = Pointer to a #gint64 to store the result
887 	 *
888 	 * Returns: %TRUE if successful, %FALSE otherwise.
889 	 */
890 	public bool peekInt64Le(out long val)
891 	{
892 		return gst_byte_reader_peek_int64_le(gstByteReader, &val) != 0;
893 	}
894 
895 	/**
896 	 * Read a signed 8 bit integer into @val but keep the current position.
897 	 *
898 	 * Params:
899 	 *     val = Pointer to a #gint8 to store the result
900 	 *
901 	 * Returns: %TRUE if successful, %FALSE otherwise.
902 	 */
903 	public bool peekInt8(out byte val)
904 	{
905 		return gst_byte_reader_peek_int8(gstByteReader, &val) != 0;
906 	}
907 
908 	/**
909 	 * Returns a constant pointer to the current data position if there is
910 	 * a NUL-terminated string in the data (this could be just a NUL terminator).
911 	 * The current position will be maintained. This will work for any
912 	 * NUL-terminated string with a character width of 8 bits, so ASCII,
913 	 * UTF-8, ISO-8859-N etc.
914 	 *
915 	 * No input checking for valid UTF-8 is done.
916 	 *
917 	 * This function will fail if no NUL-terminator was found in in the data.
918 	 *
919 	 * Params:
920 	 *     str = address of a
921 	 *         #gchar pointer variable in which to store the result
922 	 *
923 	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
924 	 */
925 	public bool peekStringUtf8(out string str)
926 	{
927 		char* outstr = null;
928 
929 		auto p = gst_byte_reader_peek_string_utf8(gstByteReader, &outstr) != 0;
930 
931 		str = Str.toString(outstr);
932 
933 		return p;
934 	}
935 
936 	/**
937 	 * Initializes a #GstByteReader sub-reader instance to contain @size bytes of
938 	 * data from the current position of @reader. This is useful to read chunked
939 	 * formats and make sure that one doesn't read beyond the size of the sub-chunk.
940 	 *
941 	 * Unlike gst_byte_reader_get_sub_reader(), this function does not modify the
942 	 * current position of @reader.
943 	 *
944 	 * Params:
945 	 *     subReader = a #GstByteReader instance to initialize as sub-reader
946 	 *     size = size of @sub_reader in bytes
947 	 *
948 	 * Returns: FALSE on error or if @reader does not contain @size more bytes from
949 	 *     the current position, and otherwise TRUE
950 	 *
951 	 * Since: 1.6
952 	 */
953 	public bool peekSubReader(ByteReader subReader, uint size)
954 	{
955 		return gst_byte_reader_peek_sub_reader(gstByteReader, (subReader is null) ? null : subReader.getByteReaderStruct(), size) != 0;
956 	}
957 
958 	/**
959 	 * Read an unsigned 16 bit big endian integer into @val
960 	 * but keep the current position.
961 	 *
962 	 * Params:
963 	 *     val = Pointer to a #guint16 to store the result
964 	 *
965 	 * Returns: %TRUE if successful, %FALSE otherwise.
966 	 */
967 	public bool peekUint16Be(out ushort val)
968 	{
969 		return gst_byte_reader_peek_uint16_be(gstByteReader, &val) != 0;
970 	}
971 
972 	/**
973 	 * Read an unsigned 16 bit little endian integer into @val
974 	 * but keep the current position.
975 	 *
976 	 * Params:
977 	 *     val = Pointer to a #guint16 to store the result
978 	 *
979 	 * Returns: %TRUE if successful, %FALSE otherwise.
980 	 */
981 	public bool peekUint16Le(out ushort val)
982 	{
983 		return gst_byte_reader_peek_uint16_le(gstByteReader, &val) != 0;
984 	}
985 
986 	/**
987 	 * Read an unsigned 24 bit big endian integer into @val
988 	 * but keep the current position.
989 	 *
990 	 * Params:
991 	 *     val = Pointer to a #guint32 to store the result
992 	 *
993 	 * Returns: %TRUE if successful, %FALSE otherwise.
994 	 */
995 	public bool peekUint24Be(out uint val)
996 	{
997 		return gst_byte_reader_peek_uint24_be(gstByteReader, &val) != 0;
998 	}
999 
1000 	/**
1001 	 * Read an unsigned 24 bit little endian integer into @val
1002 	 * but keep the current position.
1003 	 *
1004 	 * Params:
1005 	 *     val = Pointer to a #guint32 to store the result
1006 	 *
1007 	 * Returns: %TRUE if successful, %FALSE otherwise.
1008 	 */
1009 	public bool peekUint24Le(out uint val)
1010 	{
1011 		return gst_byte_reader_peek_uint24_le(gstByteReader, &val) != 0;
1012 	}
1013 
1014 	/**
1015 	 * Read an unsigned 32 bit big endian integer into @val
1016 	 * but keep the current position.
1017 	 *
1018 	 * Params:
1019 	 *     val = Pointer to a #guint32 to store the result
1020 	 *
1021 	 * Returns: %TRUE if successful, %FALSE otherwise.
1022 	 */
1023 	public bool peekUint32Be(out uint val)
1024 	{
1025 		return gst_byte_reader_peek_uint32_be(gstByteReader, &val) != 0;
1026 	}
1027 
1028 	/**
1029 	 * Read an unsigned 32 bit little endian integer into @val
1030 	 * but keep the current position.
1031 	 *
1032 	 * Params:
1033 	 *     val = Pointer to a #guint32 to store the result
1034 	 *
1035 	 * Returns: %TRUE if successful, %FALSE otherwise.
1036 	 */
1037 	public bool peekUint32Le(out uint val)
1038 	{
1039 		return gst_byte_reader_peek_uint32_le(gstByteReader, &val) != 0;
1040 	}
1041 
1042 	/**
1043 	 * Read an unsigned 64 bit big endian integer into @val
1044 	 * but keep the current position.
1045 	 *
1046 	 * Params:
1047 	 *     val = Pointer to a #guint64 to store the result
1048 	 *
1049 	 * Returns: %TRUE if successful, %FALSE otherwise.
1050 	 */
1051 	public bool peekUint64Be(out ulong val)
1052 	{
1053 		return gst_byte_reader_peek_uint64_be(gstByteReader, &val) != 0;
1054 	}
1055 
1056 	/**
1057 	 * Read an unsigned 64 bit little endian integer into @val
1058 	 * but keep the current position.
1059 	 *
1060 	 * Params:
1061 	 *     val = Pointer to a #guint64 to store the result
1062 	 *
1063 	 * Returns: %TRUE if successful, %FALSE otherwise.
1064 	 */
1065 	public bool peekUint64Le(out ulong val)
1066 	{
1067 		return gst_byte_reader_peek_uint64_le(gstByteReader, &val) != 0;
1068 	}
1069 
1070 	/**
1071 	 * Read an unsigned 8 bit integer into @val but keep the current position.
1072 	 *
1073 	 * Params:
1074 	 *     val = Pointer to a #guint8 to store the result
1075 	 *
1076 	 * Returns: %TRUE if successful, %FALSE otherwise.
1077 	 */
1078 	public bool peekUint8(out ubyte val)
1079 	{
1080 		return gst_byte_reader_peek_uint8(gstByteReader, &val) != 0;
1081 	}
1082 
1083 	/**
1084 	 * Sets the new position of a #GstByteReader instance to @pos in bytes.
1085 	 *
1086 	 * Params:
1087 	 *     pos = The new position in bytes
1088 	 *
1089 	 * Returns: %TRUE if the position could be set successfully, %FALSE
1090 	 *     otherwise.
1091 	 */
1092 	public bool setPos(uint pos)
1093 	{
1094 		return gst_byte_reader_set_pos(gstByteReader, pos) != 0;
1095 	}
1096 
1097 	/**
1098 	 * Skips @nbytes bytes of the #GstByteReader instance.
1099 	 *
1100 	 * Params:
1101 	 *     nbytes = the number of bytes to skip
1102 	 *
1103 	 * Returns: %TRUE if @nbytes bytes could be skipped, %FALSE otherwise.
1104 	 */
1105 	public bool skip(uint nbytes)
1106 	{
1107 		return gst_byte_reader_skip(gstByteReader, nbytes) != 0;
1108 	}
1109 
1110 	/**
1111 	 * Skips a NUL-terminated UTF-16 string in the #GstByteReader instance,
1112 	 * advancing the current position to the byte after the string.
1113 	 *
1114 	 * No input checking for valid UTF-16 is done.
1115 	 *
1116 	 * This function will fail if no NUL-terminator was found in in the data.
1117 	 *
1118 	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
1119 	 */
1120 	public bool skipStringUtf16()
1121 	{
1122 		return gst_byte_reader_skip_string_utf16(gstByteReader) != 0;
1123 	}
1124 
1125 	/**
1126 	 * Skips a NUL-terminated UTF-32 string in the #GstByteReader instance,
1127 	 * advancing the current position to the byte after the string.
1128 	 *
1129 	 * No input checking for valid UTF-32 is done.
1130 	 *
1131 	 * This function will fail if no NUL-terminator was found in in the data.
1132 	 *
1133 	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
1134 	 */
1135 	public bool skipStringUtf32()
1136 	{
1137 		return gst_byte_reader_skip_string_utf32(gstByteReader) != 0;
1138 	}
1139 
1140 	/**
1141 	 * Skips a NUL-terminated string in the #GstByteReader instance, advancing
1142 	 * the current position to the byte after the string. This will work for
1143 	 * any NUL-terminated string with a character width of 8 bits, so ASCII,
1144 	 * UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.
1145 	 *
1146 	 * This function will fail if no NUL-terminator was found in in the data.
1147 	 *
1148 	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
1149 	 */
1150 	public bool skipStringUtf8()
1151 	{
1152 		return gst_byte_reader_skip_string_utf8(gstByteReader) != 0;
1153 	}
1154 
1155 	/**
1156 	 * Create a new #GstByteReader instance, which will read from @data.
1157 	 *
1158 	 * Free-function: gst_byte_reader_free
1159 	 *
1160 	 * Params:
1161 	 *     data = data from which the
1162 	 *         #GstByteReader should read
1163 	 *
1164 	 * Returns: a new #GstByteReader instance
1165 	 *
1166 	 * Throws: ConstructionException GTK+ fails to create the object.
1167 	 */
1168 	public this(ubyte[] data)
1169 	{
1170 		auto p = gst_byte_reader_new(data.ptr, cast(uint)data.length);
1171 
1172 		if(p is null)
1173 		{
1174 			throw new ConstructionException("null returned by new");
1175 		}
1176 
1177 		this(cast(GstByteReader*) p);
1178 	}
1179 }