File: ByteReader.d

package info (click to toggle)
gtk-d 3.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 20,152 kB
  • sloc: javascript: 565; sh: 71; makefile: 25
file content (1179 lines) | stat: -rw-r--r-- 32,486 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage


module gst.base.ByteReader;

private import glib.ConstructionException;
private import glib.Str;
private import gobject.ObjectG;
private import gst.base.c.functions;
public  import gst.base.c.types;
private import gtkd.Loader;


/**
 * #GstByteReader provides a byte reader that can read different integer and
 * floating point types from a memory buffer. It provides functions for reading
 * signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits
 * and functions for reading little/big endian floating points numbers of
 * 32 and 64 bits. It also provides functions to read NUL-terminated strings
 * in various character encodings.
 */
public class ByteReader
{
	/** the main Gtk struct */
	protected GstByteReader* gstByteReader;
	protected bool ownedRef;

	/** Get the main Gtk struct */
	public GstByteReader* getByteReaderStruct(bool transferOwnership = false)
	{
		if (transferOwnership)
			ownedRef = false;
		return gstByteReader;
	}

	/** the main Gtk struct as a void* */
	protected void* getStruct()
	{
		return cast(void*)gstByteReader;
	}

	/**
	 * Sets our main struct and passes it to the parent class.
	 */
	public this (GstByteReader* gstByteReader, bool ownedRef = false)
	{
		this.gstByteReader = gstByteReader;
		this.ownedRef = ownedRef;
	}

	~this ()
	{
		if ( Linker.isLoaded(LIBRARY_GSTBASE) && ownedRef )
			gst_byte_reader_free(gstByteReader);
	}


	/**
	 * Free-function: g_free
	 *
	 * Returns a newly-allocated copy of the current data
	 * position if at least @size bytes are left and
	 * updates the current position. Free with g_free() when no longer needed.
	 *
	 * Params:
	 *     val = address of a
	 *         #guint8 pointer variable in which to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool dupData(out ubyte[] val)
	{
		ubyte* outval = null;

		auto p = gst_byte_reader_dup_data(gstByteReader, cast(uint)val.length, &outval) != 0;

		val = outval[0 .. cast(uint)val.length];

		return p;
	}

	/**
	 * Free-function: g_free
	 *
	 * Returns a newly-allocated copy of the current data position if there is
	 * a NUL-terminated UTF-16 string in the data (this could be an empty string
	 * as well), and advances the current position.
	 *
	 * No input checking for valid UTF-16 is done. This function is endianness
	 * agnostic - you should not assume the UTF-16 characters are in host
	 * endianness.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Note: there is no peek or get variant of this function to ensure correct
	 * byte alignment of the UTF-16 string.
	 *
	 * Params:
	 *     str = address of a
	 *         #guint16 pointer variable in which to store the result
	 *
	 * Returns: %TRUE if a string could be read, %FALSE otherwise. The
	 *     string put into @str must be freed with g_free() when no longer needed.
	 */
	public bool dupStringUtf16(out ushort[] str)
	{
		ushort* outstr = null;

		auto p = gst_byte_reader_dup_string_utf16(gstByteReader, &outstr) != 0;

		str = outstr[0 .. getArrayLength(outstr)];

		return p;
	}

	/**
	 * Free-function: g_free
	 *
	 * Returns a newly-allocated copy of the current data position if there is
	 * a NUL-terminated UTF-32 string in the data (this could be an empty string
	 * as well), and advances the current position.
	 *
	 * No input checking for valid UTF-32 is done. This function is endianness
	 * agnostic - you should not assume the UTF-32 characters are in host
	 * endianness.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Note: there is no peek or get variant of this function to ensure correct
	 * byte alignment of the UTF-32 string.
	 *
	 * Params:
	 *     str = address of a
	 *         #guint32 pointer variable in which to store the result
	 *
	 * Returns: %TRUE if a string could be read, %FALSE otherwise. The
	 *     string put into @str must be freed with g_free() when no longer needed.
	 */
	public bool dupStringUtf32(out uint[] str)
	{
		uint* outstr = null;

		auto p = gst_byte_reader_dup_string_utf32(gstByteReader, &outstr) != 0;

		str = outstr[0 .. getArrayLength(outstr)];

		return p;
	}

	/**
	 * Free-function: g_free
	 *
	 * FIXME:Reads (copies) a NUL-terminated string in the #GstByteReader instance,
	 * advancing the current position to the byte after the string. This will work
	 * for any NUL-terminated string with a character width of 8 bits, so ASCII,
	 * UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Params:
	 *     str = address of a
	 *         #gchar pointer variable in which to store the result
	 *
	 * Returns: %TRUE if a string could be read into @str, %FALSE otherwise. The
	 *     string put into @str must be freed with g_free() when no longer needed.
	 */
	public bool dupStringUtf8(out string str)
	{
		char* outstr = null;

		auto p = gst_byte_reader_dup_string_utf8(gstByteReader, &outstr) != 0;

		str = Str.toString(outstr);

		return p;
	}

	/**
	 * Frees a #GstByteReader instance, which was previously allocated by
	 * gst_byte_reader_new().
	 */
	public void free()
	{
		gst_byte_reader_free(gstByteReader);
		ownedRef = false;
	}

	/**
	 * Returns a constant pointer to the current data
	 * position if at least @size bytes are left and
	 * updates the current position.
	 *
	 * Params:
	 *     val = address of a
	 *         #guint8 pointer variable in which to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getData(out ubyte[] val)
	{
		ubyte* outval = null;

		auto p = gst_byte_reader_get_data(gstByteReader, cast(uint)val.length, &outval) != 0;

		val = outval[0 .. cast(uint)val.length];

		return p;
	}

	/**
	 * Read a 32 bit big endian floating point value into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gfloat to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getFloat32Be(out float val)
	{
		return gst_byte_reader_get_float32_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a 32 bit little endian floating point value into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gfloat to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getFloat32Le(out float val)
	{
		return gst_byte_reader_get_float32_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a 64 bit big endian floating point value into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gdouble to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getFloat64Be(out double val)
	{
		return gst_byte_reader_get_float64_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a 64 bit little endian floating point value into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gdouble to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getFloat64Le(out double val)
	{
		return gst_byte_reader_get_float64_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 16 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt16Be(out short val)
	{
		return gst_byte_reader_get_int16_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 16 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt16Le(out short val)
	{
		return gst_byte_reader_get_int16_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 24 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt24Be(out int val)
	{
		return gst_byte_reader_get_int24_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 24 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt24Le(out int val)
	{
		return gst_byte_reader_get_int24_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 32 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt32Be(out int val)
	{
		return gst_byte_reader_get_int32_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 32 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt32Le(out int val)
	{
		return gst_byte_reader_get_int32_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 64 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt64Be(out long val)
	{
		return gst_byte_reader_get_int64_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 64 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt64Le(out long val)
	{
		return gst_byte_reader_get_int64_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 8 bit integer into @val and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint8 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getInt8(out byte val)
	{
		return gst_byte_reader_get_int8(gstByteReader, &val) != 0;
	}

	/**
	 * Returns the current position of a #GstByteReader instance in bytes.
	 *
	 * Returns: The current position of @reader in bytes.
	 */
	public uint getPos()
	{
		return gst_byte_reader_get_pos(gstByteReader);
	}

	/**
	 * Returns the remaining number of bytes of a #GstByteReader instance.
	 *
	 * Returns: The remaining number of bytes of @reader instance.
	 */
	public uint getRemaining()
	{
		return gst_byte_reader_get_remaining(gstByteReader);
	}

	/**
	 * Returns the total number of bytes of a #GstByteReader instance.
	 *
	 * Returns: The total number of bytes of @reader instance.
	 */
	public uint getSize()
	{
		return gst_byte_reader_get_size(gstByteReader);
	}

	/**
	 * Returns a constant pointer to the current data position if there is
	 * a NUL-terminated string in the data (this could be just a NUL terminator),
	 * advancing the current position to the byte after the string. This will work
	 * for any NUL-terminated string with a character width of 8 bits, so ASCII,
	 * UTF-8, ISO-8859-N etc.
	 *
	 * No input checking for valid UTF-8 is done.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Params:
	 *     str = address of a
	 *         #gchar pointer variable in which to store the result
	 *
	 * Returns: %TRUE if a string could be found, %FALSE otherwise.
	 */
	public bool getStringUtf8(out string str)
	{
		char* outstr = null;

		auto p = gst_byte_reader_get_string_utf8(gstByteReader, &outstr) != 0;

		str = Str.toString(outstr);

		return p;
	}

	/**
	 * Initializes a #GstByteReader sub-reader instance to contain @size bytes of
	 * data from the current position of @reader. This is useful to read chunked
	 * formats and make sure that one doesn't read beyond the size of the sub-chunk.
	 *
	 * Unlike gst_byte_reader_peek_sub_reader(), this function also modifies the
	 * position of @reader and moves it forward by @size bytes.
	 *
	 * Params:
	 *     subReader = a #GstByteReader instance to initialize as sub-reader
	 *     size = size of @sub_reader in bytes
	 *
	 * Returns: FALSE on error or if @reader does not contain @size more bytes from
	 *     the current position, and otherwise TRUE
	 *
	 * Since: 1.6
	 */
	public bool getSubReader(ByteReader subReader, uint size)
	{
		return gst_byte_reader_get_sub_reader(gstByteReader, (subReader is null) ? null : subReader.getByteReaderStruct(), size) != 0;
	}

	/**
	 * Read an unsigned 16 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint16Be(out ushort val)
	{
		return gst_byte_reader_get_uint16_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 16 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint16Le(out ushort val)
	{
		return gst_byte_reader_get_uint16_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 24 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint24Be(out uint val)
	{
		return gst_byte_reader_get_uint24_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 24 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint24Le(out uint val)
	{
		return gst_byte_reader_get_uint24_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 32 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint32Be(out uint val)
	{
		return gst_byte_reader_get_uint32_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 32 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint32Le(out uint val)
	{
		return gst_byte_reader_get_uint32_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 64 bit big endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint64Be(out ulong val)
	{
		return gst_byte_reader_get_uint64_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 64 bit little endian integer into @val
	 * and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint64Le(out ulong val)
	{
		return gst_byte_reader_get_uint64_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 8 bit integer into @val and update the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint8 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool getUint8(out ubyte val)
	{
		return gst_byte_reader_get_uint8(gstByteReader, &val) != 0;
	}

	/**
	 * Initializes a #GstByteReader instance to read from @data. This function
	 * can be called on already initialized instances.
	 *
	 * Params:
	 *     data = data from which
	 *         the #GstByteReader should read
	 */
	public void init(ubyte[] data)
	{
		gst_byte_reader_init(gstByteReader, data.ptr, cast(uint)data.length);
	}

	/**
	 * Scan for pattern @pattern with applied mask @mask in the byte reader data,
	 * starting from offset @offset relative to the current position.
	 *
	 * The bytes in @pattern and @mask are interpreted left-to-right, regardless
	 * of endianness.  All four bytes of the pattern must be present in the
	 * byte reader data for it to match, even if the first or last bytes are masked
	 * out.
	 *
	 * It is an error to call this function without making sure that there is
	 * enough data (offset+size bytes) in the byte reader.
	 *
	 * Params:
	 *     mask = mask to apply to data before matching against @pattern
	 *     pattern = pattern to match (after mask is applied)
	 *     offset = offset from which to start scanning, relative to the current
	 *         position
	 *     size = number of bytes to scan from offset
	 *
	 * Returns: offset of the first match, or -1 if no match was found.
	 *
	 *     Example:
	 *     |[
	 *     // Assume the reader contains 0x00 0x01 0x02 ... 0xfe 0xff
	 *
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 0, 256);
	 *     // -> returns 0
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x00010203, 1, 255);
	 *     // -> returns -1
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffffffff, 0x01020304, 1, 255);
	 *     // -> returns 1
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0001, 0, 256);
	 *     // -> returns -1
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff, 0x0203, 0, 256);
	 *     // -> returns 0
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 256);
	 *     // -> returns 2
	 *     gst_byte_reader_masked_scan_uint32 (reader, 0xffff0000, 0x02030000, 0, 4);
	 *     // -> returns -1
	 *     ]|
	 */
	public uint maskedScanUint32(uint mask, uint pattern, uint offset, uint size)
	{
		return gst_byte_reader_masked_scan_uint32(gstByteReader, mask, pattern, offset, size);
	}

	/**
	 * Scan for pattern @pattern with applied mask @mask in the byte reader data,
	 * starting from offset @offset relative to the current position.
	 *
	 * The bytes in @pattern and @mask are interpreted left-to-right, regardless
	 * of endianness.  All four bytes of the pattern must be present in the
	 * byte reader data for it to match, even if the first or last bytes are masked
	 * out.
	 *
	 * It is an error to call this function without making sure that there is
	 * enough data (offset+size bytes) in the byte reader.
	 *
	 * Params:
	 *     mask = mask to apply to data before matching against @pattern
	 *     pattern = pattern to match (after mask is applied)
	 *     offset = offset from which to start scanning, relative to the current
	 *         position
	 *     size = number of bytes to scan from offset
	 *     value = pointer to uint32 to return matching data
	 *
	 * Returns: offset of the first match, or -1 if no match was found.
	 *
	 * Since: 1.6
	 */
	public uint maskedScanUint32Peek(uint mask, uint pattern, uint offset, uint size, out uint value)
	{
		return gst_byte_reader_masked_scan_uint32_peek(gstByteReader, mask, pattern, offset, size, &value);
	}

	/**
	 * Returns a constant pointer to the current data
	 * position if at least @size bytes are left and
	 * keeps the current position.
	 *
	 * Params:
	 *     val = address of a
	 *         #guint8 pointer variable in which to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekData(out ubyte[] val)
	{
		ubyte* outval = null;

		auto p = gst_byte_reader_peek_data(gstByteReader, cast(uint)val.length, &outval) != 0;

		val = outval[0 .. cast(uint)val.length];

		return p;
	}

	/**
	 * Read a 32 bit big endian floating point value into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gfloat to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekFloat32Be(out float val)
	{
		return gst_byte_reader_peek_float32_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a 32 bit little endian floating point value into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gfloat to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekFloat32Le(out float val)
	{
		return gst_byte_reader_peek_float32_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a 64 bit big endian floating point value into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gdouble to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekFloat64Be(out double val)
	{
		return gst_byte_reader_peek_float64_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a 64 bit little endian floating point value into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gdouble to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekFloat64Le(out double val)
	{
		return gst_byte_reader_peek_float64_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 16 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt16Be(out short val)
	{
		return gst_byte_reader_peek_int16_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 16 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt16Le(out short val)
	{
		return gst_byte_reader_peek_int16_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 24 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt24Be(out int val)
	{
		return gst_byte_reader_peek_int24_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 24 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt24Le(out int val)
	{
		return gst_byte_reader_peek_int24_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 32 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt32Be(out int val)
	{
		return gst_byte_reader_peek_int32_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 32 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt32Le(out int val)
	{
		return gst_byte_reader_peek_int32_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 64 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt64Be(out long val)
	{
		return gst_byte_reader_peek_int64_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 64 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt64Le(out long val)
	{
		return gst_byte_reader_peek_int64_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read a signed 8 bit integer into @val but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #gint8 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekInt8(out byte val)
	{
		return gst_byte_reader_peek_int8(gstByteReader, &val) != 0;
	}

	/**
	 * Returns a constant pointer to the current data position if there is
	 * a NUL-terminated string in the data (this could be just a NUL terminator).
	 * The current position will be maintained. This will work for any
	 * NUL-terminated string with a character width of 8 bits, so ASCII,
	 * UTF-8, ISO-8859-N etc.
	 *
	 * No input checking for valid UTF-8 is done.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Params:
	 *     str = address of a
	 *         #gchar pointer variable in which to store the result
	 *
	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
	 */
	public bool peekStringUtf8(out string str)
	{
		char* outstr = null;

		auto p = gst_byte_reader_peek_string_utf8(gstByteReader, &outstr) != 0;

		str = Str.toString(outstr);

		return p;
	}

	/**
	 * Initializes a #GstByteReader sub-reader instance to contain @size bytes of
	 * data from the current position of @reader. This is useful to read chunked
	 * formats and make sure that one doesn't read beyond the size of the sub-chunk.
	 *
	 * Unlike gst_byte_reader_get_sub_reader(), this function does not modify the
	 * current position of @reader.
	 *
	 * Params:
	 *     subReader = a #GstByteReader instance to initialize as sub-reader
	 *     size = size of @sub_reader in bytes
	 *
	 * Returns: FALSE on error or if @reader does not contain @size more bytes from
	 *     the current position, and otherwise TRUE
	 *
	 * Since: 1.6
	 */
	public bool peekSubReader(ByteReader subReader, uint size)
	{
		return gst_byte_reader_peek_sub_reader(gstByteReader, (subReader is null) ? null : subReader.getByteReaderStruct(), size) != 0;
	}

	/**
	 * Read an unsigned 16 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint16Be(out ushort val)
	{
		return gst_byte_reader_peek_uint16_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 16 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint16 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint16Le(out ushort val)
	{
		return gst_byte_reader_peek_uint16_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 24 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint24Be(out uint val)
	{
		return gst_byte_reader_peek_uint24_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 24 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint24Le(out uint val)
	{
		return gst_byte_reader_peek_uint24_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 32 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint32Be(out uint val)
	{
		return gst_byte_reader_peek_uint32_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 32 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint32 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint32Le(out uint val)
	{
		return gst_byte_reader_peek_uint32_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 64 bit big endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint64Be(out ulong val)
	{
		return gst_byte_reader_peek_uint64_be(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 64 bit little endian integer into @val
	 * but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint64 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint64Le(out ulong val)
	{
		return gst_byte_reader_peek_uint64_le(gstByteReader, &val) != 0;
	}

	/**
	 * Read an unsigned 8 bit integer into @val but keep the current position.
	 *
	 * Params:
	 *     val = Pointer to a #guint8 to store the result
	 *
	 * Returns: %TRUE if successful, %FALSE otherwise.
	 */
	public bool peekUint8(out ubyte val)
	{
		return gst_byte_reader_peek_uint8(gstByteReader, &val) != 0;
	}

	/**
	 * Sets the new position of a #GstByteReader instance to @pos in bytes.
	 *
	 * Params:
	 *     pos = The new position in bytes
	 *
	 * Returns: %TRUE if the position could be set successfully, %FALSE
	 *     otherwise.
	 */
	public bool setPos(uint pos)
	{
		return gst_byte_reader_set_pos(gstByteReader, pos) != 0;
	}

	/**
	 * Skips @nbytes bytes of the #GstByteReader instance.
	 *
	 * Params:
	 *     nbytes = the number of bytes to skip
	 *
	 * Returns: %TRUE if @nbytes bytes could be skipped, %FALSE otherwise.
	 */
	public bool skip(uint nbytes)
	{
		return gst_byte_reader_skip(gstByteReader, nbytes) != 0;
	}

	/**
	 * Skips a NUL-terminated UTF-16 string in the #GstByteReader instance,
	 * advancing the current position to the byte after the string.
	 *
	 * No input checking for valid UTF-16 is done.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
	 */
	public bool skipStringUtf16()
	{
		return gst_byte_reader_skip_string_utf16(gstByteReader) != 0;
	}

	/**
	 * Skips a NUL-terminated UTF-32 string in the #GstByteReader instance,
	 * advancing the current position to the byte after the string.
	 *
	 * No input checking for valid UTF-32 is done.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
	 */
	public bool skipStringUtf32()
	{
		return gst_byte_reader_skip_string_utf32(gstByteReader) != 0;
	}

	/**
	 * Skips a NUL-terminated string in the #GstByteReader instance, advancing
	 * the current position to the byte after the string. This will work for
	 * any NUL-terminated string with a character width of 8 bits, so ASCII,
	 * UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done.
	 *
	 * This function will fail if no NUL-terminator was found in in the data.
	 *
	 * Returns: %TRUE if a string could be skipped, %FALSE otherwise.
	 */
	public bool skipStringUtf8()
	{
		return gst_byte_reader_skip_string_utf8(gstByteReader) != 0;
	}

	/**
	 * Create a new #GstByteReader instance, which will read from @data.
	 *
	 * Free-function: gst_byte_reader_free
	 *
	 * Params:
	 *     data = data from which the
	 *         #GstByteReader should read
	 *
	 * Returns: a new #GstByteReader instance
	 *
	 * Throws: ConstructionException GTK+ fails to create the object.
	 */
	public this(ubyte[] data)
	{
		auto p = gst_byte_reader_new(data.ptr, cast(uint)data.length);

		if(p is null)
		{
			throw new ConstructionException("null returned by new");
		}

		this(cast(GstByteReader*) p);
	}
}