-
Notifications
You must be signed in to change notification settings - Fork 31
/
gif.cpp
2452 lines (2138 loc) · 73.9 KB
/
gif.cpp
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
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <unordered_map>
#include "bt.h"
class char_class {
int small;
std::vector<char> known_values;
char value;
public:
int64 _startof = 0;
std::size_t _sizeof = sizeof(char);
char operator () () { return value; }
char_class(int small, std::vector<char> known_values = {}) : small(small), known_values(known_values) {}
char generate() {
_startof = FTell();
if (known_values.empty()) {
value = file_acc.file_integer(sizeof(char), 0, small);
} else {
value = file_acc.file_integer(sizeof(char), 0, known_values);
}
return value;
}
char generate(std::vector<char> possible_values) {
_startof = FTell();
value = file_acc.file_integer(sizeof(char), 0, possible_values);
return value;
}
};
class char_array_class {
char_class& element;
std::vector<std::string> known_values;
std::unordered_map<int, std::vector<char>> element_known_values;
std::string value;
public:
int64 _startof = 0;
std::size_t _sizeof = 0;
std::string operator () () { return value; }
char operator [] (int index) {
assert_cond((unsigned)index < value.size(), "array index out of bounds");
return value[index];
}
char_array_class(char_class& element, std::unordered_map<int, std::vector<char>> element_known_values = {})
: element(element), element_known_values(element_known_values) {}
char_array_class(char_class& element, std::vector<std::string> known_values)
: element(element), known_values(known_values) {}
std::string generate(unsigned size, std::vector<std::string> possible_values = {}) {
check_array_length(size);
_startof = FTell();
value = "";
if (possible_values.size()) {
value = file_acc.file_string(possible_values);
assert(value.length() == size);
_sizeof = size;
return value;
}
if (known_values.size()) {
value = file_acc.file_string(known_values);
assert(value.length() == size);
_sizeof = size;
return value;
}
if (!element_known_values.size()) {
if (size == 0)
return "";
value = file_acc.file_string(size);
_sizeof = size;
return value;
}
for (unsigned i = 0; i < size; ++i) {
auto known = element_known_values.find(i);
if (known == element_known_values.end()) {
value.push_back(element.generate());
_sizeof += element._sizeof;
} else {
value.push_back(file_acc.file_integer(sizeof(char), 0, known->second));
_sizeof += sizeof(char);
}
}
return value;
}
};
class GIFHEADER {
std::vector<GIFHEADER*>& instances;
std::string Signature_var;
std::string Version_var;
public:
bool Signature_exists = false;
bool Version_exists = false;
std::string& Signature() {
assert_cond(Signature_exists, "struct field Signature does not exist");
return Signature_var;
}
std::string& Version() {
assert_cond(Version_exists, "struct field Version does not exist");
return Version_var;
}
/* locals */
int evil;
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
GIFHEADER& operator () () { return *instances.back(); }
GIFHEADER& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
GIFHEADER(std::vector<GIFHEADER*>& instances) : instances(instances) { instances.push_back(this); }
~GIFHEADER() {
if (generated == 2)
return;
while (instances.size()) {
GIFHEADER* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
GIFHEADER* generate();
};
int GIFHEADER::_parent_id = 0;
int GIFHEADER::_index_start = 0;
class ushort_class {
int small;
std::vector<ushort> known_values;
ushort value;
public:
int64 _startof = 0;
std::size_t _sizeof = sizeof(ushort);
ushort operator () () { return value; }
ushort_class(int small, std::vector<ushort> known_values = {}) : small(small), known_values(known_values) {}
ushort generate() {
_startof = FTell();
if (known_values.empty()) {
value = file_acc.file_integer(sizeof(ushort), 0, small);
} else {
value = file_acc.file_integer(sizeof(ushort), 0, known_values);
}
return value;
}
ushort generate(std::vector<ushort> possible_values) {
_startof = FTell();
value = file_acc.file_integer(sizeof(ushort), 0, possible_values);
return value;
}
};
class UBYTE_bitfield {
int small;
std::vector<UBYTE> known_values;
UBYTE value;
public:
UBYTE operator () () { return value; }
UBYTE_bitfield(int small, std::vector<UBYTE> known_values = {}) : small(small), known_values(known_values) {}
UBYTE generate(unsigned bits) {
if (!bits)
return 0;
if (known_values.empty()) {
value = file_acc.file_integer(sizeof(UBYTE), bits, small);
} else {
value = file_acc.file_integer(sizeof(UBYTE), bits, known_values);
}
return value;
}
UBYTE generate(unsigned bits, std::vector<UBYTE> possible_values) {
if (!bits)
return 0;
value = file_acc.file_integer(sizeof(UBYTE), bits, possible_values);
return value;
}
};
class LOGICALSCREENDESCRIPTOR_PACKEDFIELDS {
std::vector<LOGICALSCREENDESCRIPTOR_PACKEDFIELDS*>& instances;
UBYTE GlobalColorTableFlag_var : 1;
UBYTE ColorResolution_var : 3;
UBYTE SortFlag_var : 1;
UBYTE SizeOfGlobalColorTable_var : 3;
public:
bool GlobalColorTableFlag_exists = false;
bool ColorResolution_exists = false;
bool SortFlag_exists = false;
bool SizeOfGlobalColorTable_exists = false;
UBYTE GlobalColorTableFlag() {
assert_cond(GlobalColorTableFlag_exists, "struct field GlobalColorTableFlag does not exist");
return GlobalColorTableFlag_var;
}
UBYTE ColorResolution() {
assert_cond(ColorResolution_exists, "struct field ColorResolution does not exist");
return ColorResolution_var;
}
UBYTE SortFlag() {
assert_cond(SortFlag_exists, "struct field SortFlag does not exist");
return SortFlag_var;
}
UBYTE SizeOfGlobalColorTable() {
assert_cond(SizeOfGlobalColorTable_exists, "struct field SizeOfGlobalColorTable does not exist");
return SizeOfGlobalColorTable_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS& operator () () { return *instances.back(); }
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS(std::vector<LOGICALSCREENDESCRIPTOR_PACKEDFIELDS*>& instances) : instances(instances) { instances.push_back(this); }
~LOGICALSCREENDESCRIPTOR_PACKEDFIELDS() {
if (generated == 2)
return;
while (instances.size()) {
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS* generate();
};
int LOGICALSCREENDESCRIPTOR_PACKEDFIELDS::_parent_id = 0;
int LOGICALSCREENDESCRIPTOR_PACKEDFIELDS::_index_start = 0;
class UBYTE_class {
int small;
std::vector<UBYTE> known_values;
UBYTE value;
public:
int64 _startof = 0;
std::size_t _sizeof = sizeof(UBYTE);
UBYTE operator () () { return value; }
UBYTE_class(int small, std::vector<UBYTE> known_values = {}) : small(small), known_values(known_values) {}
UBYTE generate() {
_startof = FTell();
if (known_values.empty()) {
value = file_acc.file_integer(sizeof(UBYTE), 0, small);
} else {
value = file_acc.file_integer(sizeof(UBYTE), 0, known_values);
}
return value;
}
UBYTE generate(std::vector<UBYTE> possible_values) {
_startof = FTell();
value = file_acc.file_integer(sizeof(UBYTE), 0, possible_values);
return value;
}
};
class LOGICALSCREENDESCRIPTOR {
std::vector<LOGICALSCREENDESCRIPTOR*>& instances;
ushort Width_var;
ushort Height_var;
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS* PackedFields_var;
UBYTE BackgroundColorIndex_var;
UBYTE PixelAspectRatio_var;
public:
bool Width_exists = false;
bool Height_exists = false;
bool PackedFields_exists = false;
bool BackgroundColorIndex_exists = false;
bool PixelAspectRatio_exists = false;
ushort& Width() {
assert_cond(Width_exists, "struct field Width does not exist");
return Width_var;
}
ushort& Height() {
assert_cond(Height_exists, "struct field Height does not exist");
return Height_var;
}
LOGICALSCREENDESCRIPTOR_PACKEDFIELDS& PackedFields() {
assert_cond(PackedFields_exists, "struct field PackedFields does not exist");
return *PackedFields_var;
}
UBYTE& BackgroundColorIndex() {
assert_cond(BackgroundColorIndex_exists, "struct field BackgroundColorIndex does not exist");
return BackgroundColorIndex_var;
}
UBYTE& PixelAspectRatio() {
assert_cond(PixelAspectRatio_exists, "struct field PixelAspectRatio does not exist");
return PixelAspectRatio_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
LOGICALSCREENDESCRIPTOR& operator () () { return *instances.back(); }
LOGICALSCREENDESCRIPTOR& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
LOGICALSCREENDESCRIPTOR(std::vector<LOGICALSCREENDESCRIPTOR*>& instances) : instances(instances) { instances.push_back(this); }
~LOGICALSCREENDESCRIPTOR() {
if (generated == 2)
return;
while (instances.size()) {
LOGICALSCREENDESCRIPTOR* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
LOGICALSCREENDESCRIPTOR* generate();
};
int LOGICALSCREENDESCRIPTOR::_parent_id = 0;
int LOGICALSCREENDESCRIPTOR::_index_start = 0;
class RGB {
std::vector<RGB*>& instances;
UBYTE R_var;
UBYTE G_var;
UBYTE B_var;
public:
bool R_exists = false;
bool G_exists = false;
bool B_exists = false;
UBYTE& R() {
assert_cond(R_exists, "struct field R does not exist");
return R_var;
}
UBYTE& G() {
assert_cond(G_exists, "struct field G does not exist");
return G_var;
}
UBYTE& B() {
assert_cond(B_exists, "struct field B does not exist");
return B_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
RGB& operator () () { return *instances.back(); }
RGB& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
RGB(std::vector<RGB*>& instances) : instances(instances) { instances.push_back(this); }
~RGB() {
if (generated == 2)
return;
while (instances.size()) {
RGB* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
RGB* generate();
};
int RGB::_parent_id = 0;
int RGB::_index_start = 0;
class RGB_array_class {
RGB& element;
std::vector<RGB*> value;
public:
int64 _startof = 0;
std::size_t _sizeof = 0;
std::vector<RGB*> operator () () { return value; }
RGB operator [] (int index) {
assert_cond((unsigned)index < value.size(), "array index out of bounds");
return *value[index];
}
RGB_array_class(RGB& element) : element(element) {}
std::vector<RGB*> generate(unsigned size) {
check_array_length(size);
_startof = FTell();
value = {};
for (unsigned i = 0; i < size; ++i) {
value.push_back(element.generate());
_sizeof += element._sizeof;
}
return value;
}
};
class GLOBALCOLORTABLE {
std::vector<GLOBALCOLORTABLE*>& instances;
std::vector<RGB*> rgb_var;
public:
bool rgb_exists = false;
std::vector<RGB*>& rgb() {
assert_cond(rgb_exists, "struct field rgb does not exist");
return rgb_var;
}
/* locals */
int i;
int size;
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
GLOBALCOLORTABLE& operator () () { return *instances.back(); }
GLOBALCOLORTABLE& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
GLOBALCOLORTABLE(std::vector<GLOBALCOLORTABLE*>& instances) : instances(instances) { instances.push_back(this); }
~GLOBALCOLORTABLE() {
if (generated == 2)
return;
while (instances.size()) {
GLOBALCOLORTABLE* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
GLOBALCOLORTABLE* generate();
};
int GLOBALCOLORTABLE::_parent_id = 0;
int GLOBALCOLORTABLE::_index_start = 0;
class IMAGEDESCRIPTOR_PACKEDFIELDS {
std::vector<IMAGEDESCRIPTOR_PACKEDFIELDS*>& instances;
UBYTE LocalColorTableFlag_var : 1;
UBYTE InterlaceFlag_var : 1;
UBYTE SortFlag_var : 1;
UBYTE Reserved_var : 2;
UBYTE SizeOfLocalColorTable_var : 3;
public:
bool LocalColorTableFlag_exists = false;
bool InterlaceFlag_exists = false;
bool SortFlag_exists = false;
bool Reserved_exists = false;
bool SizeOfLocalColorTable_exists = false;
UBYTE LocalColorTableFlag() {
assert_cond(LocalColorTableFlag_exists, "struct field LocalColorTableFlag does not exist");
return LocalColorTableFlag_var;
}
UBYTE InterlaceFlag() {
assert_cond(InterlaceFlag_exists, "struct field InterlaceFlag does not exist");
return InterlaceFlag_var;
}
UBYTE SortFlag() {
assert_cond(SortFlag_exists, "struct field SortFlag does not exist");
return SortFlag_var;
}
UBYTE Reserved() {
assert_cond(Reserved_exists, "struct field Reserved does not exist");
return Reserved_var;
}
UBYTE SizeOfLocalColorTable() {
assert_cond(SizeOfLocalColorTable_exists, "struct field SizeOfLocalColorTable does not exist");
return SizeOfLocalColorTable_var;
}
/* locals */
std::vector<UBYTE> possible_values;
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
IMAGEDESCRIPTOR_PACKEDFIELDS& operator () () { return *instances.back(); }
IMAGEDESCRIPTOR_PACKEDFIELDS& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
IMAGEDESCRIPTOR_PACKEDFIELDS(std::vector<IMAGEDESCRIPTOR_PACKEDFIELDS*>& instances) : instances(instances) { instances.push_back(this); }
~IMAGEDESCRIPTOR_PACKEDFIELDS() {
if (generated == 2)
return;
while (instances.size()) {
IMAGEDESCRIPTOR_PACKEDFIELDS* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
IMAGEDESCRIPTOR_PACKEDFIELDS* generate();
};
int IMAGEDESCRIPTOR_PACKEDFIELDS::_parent_id = 0;
int IMAGEDESCRIPTOR_PACKEDFIELDS::_index_start = 0;
class IMAGEDESCRIPTOR {
std::vector<IMAGEDESCRIPTOR*>& instances;
UBYTE ImageSeperator_var;
ushort ImageLeftPosition_var;
ushort ImageTopPosition_var;
ushort ImageWidth_var;
ushort ImageHeight_var;
IMAGEDESCRIPTOR_PACKEDFIELDS* PackedFields_var;
public:
bool ImageSeperator_exists = false;
bool ImageLeftPosition_exists = false;
bool ImageTopPosition_exists = false;
bool ImageWidth_exists = false;
bool ImageHeight_exists = false;
bool PackedFields_exists = false;
UBYTE& ImageSeperator() {
assert_cond(ImageSeperator_exists, "struct field ImageSeperator does not exist");
return ImageSeperator_var;
}
ushort& ImageLeftPosition() {
assert_cond(ImageLeftPosition_exists, "struct field ImageLeftPosition does not exist");
return ImageLeftPosition_var;
}
ushort& ImageTopPosition() {
assert_cond(ImageTopPosition_exists, "struct field ImageTopPosition does not exist");
return ImageTopPosition_var;
}
ushort& ImageWidth() {
assert_cond(ImageWidth_exists, "struct field ImageWidth does not exist");
return ImageWidth_var;
}
ushort& ImageHeight() {
assert_cond(ImageHeight_exists, "struct field ImageHeight does not exist");
return ImageHeight_var;
}
IMAGEDESCRIPTOR_PACKEDFIELDS& PackedFields() {
assert_cond(PackedFields_exists, "struct field PackedFields does not exist");
return *PackedFields_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
IMAGEDESCRIPTOR& operator () () { return *instances.back(); }
IMAGEDESCRIPTOR& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
IMAGEDESCRIPTOR(std::vector<IMAGEDESCRIPTOR*>& instances) : instances(instances) { instances.push_back(this); }
~IMAGEDESCRIPTOR() {
if (generated == 2)
return;
while (instances.size()) {
IMAGEDESCRIPTOR* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
IMAGEDESCRIPTOR* generate();
};
int IMAGEDESCRIPTOR::_parent_id = 0;
int IMAGEDESCRIPTOR::_index_start = 0;
class LOCALCOLORTABLE {
std::vector<LOCALCOLORTABLE*>& instances;
std::vector<RGB*> rgb_var;
public:
bool rgb_exists = false;
std::vector<RGB*>& rgb() {
assert_cond(rgb_exists, "struct field rgb does not exist");
return rgb_var;
}
/* locals */
int i;
int size;
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
LOCALCOLORTABLE& operator () () { return *instances.back(); }
LOCALCOLORTABLE& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
LOCALCOLORTABLE(std::vector<LOCALCOLORTABLE*>& instances) : instances(instances) { instances.push_back(this); }
~LOCALCOLORTABLE() {
if (generated == 2)
return;
while (instances.size()) {
LOCALCOLORTABLE* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
LOCALCOLORTABLE* generate();
};
int LOCALCOLORTABLE::_parent_id = 0;
int LOCALCOLORTABLE::_index_start = 0;
class DATASUBBLOCK {
std::vector<DATASUBBLOCK*>& instances;
UBYTE Size_var;
std::string Data_var;
public:
bool Size_exists = false;
bool Data_exists = false;
UBYTE& Size() {
assert_cond(Size_exists, "struct field Size does not exist");
return Size_var;
}
std::string& Data() {
assert_cond(Data_exists, "struct field Data does not exist");
return Data_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
DATASUBBLOCK& operator () () { return *instances.back(); }
DATASUBBLOCK& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
DATASUBBLOCK(std::vector<DATASUBBLOCK*>& instances) : instances(instances) { instances.push_back(this); }
~DATASUBBLOCK() {
if (generated == 2)
return;
while (instances.size()) {
DATASUBBLOCK* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
DATASUBBLOCK* generate(UBYTE& size);
};
int DATASUBBLOCK::_parent_id = 0;
int DATASUBBLOCK::_index_start = 0;
class DATASUBBLOCKS {
std::vector<DATASUBBLOCKS*>& instances;
DATASUBBLOCK* DataSubBlock_var;
UBYTE BlockTerminator_var;
public:
bool DataSubBlock_exists = false;
bool BlockTerminator_exists = false;
DATASUBBLOCK& DataSubBlock() {
assert_cond(DataSubBlock_exists, "struct field DataSubBlock does not exist");
return *DataSubBlock_var;
}
UBYTE& BlockTerminator() {
assert_cond(BlockTerminator_exists, "struct field BlockTerminator does not exist");
return BlockTerminator_var;
}
/* locals */
std::vector<UBYTE> values;
int count;
UBYTE size;
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
DATASUBBLOCKS& operator () () { return *instances.back(); }
DATASUBBLOCKS& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
DATASUBBLOCKS(std::vector<DATASUBBLOCKS*>& instances) : instances(instances) { instances.push_back(this); }
~DATASUBBLOCKS() {
if (generated == 2)
return;
while (instances.size()) {
DATASUBBLOCKS* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
DATASUBBLOCKS* generate();
};
int DATASUBBLOCKS::_parent_id = 0;
int DATASUBBLOCKS::_index_start = 0;
class IMAGEDATA {
std::vector<IMAGEDATA*>& instances;
UBYTE LZWMinimumCodeSize_var;
DATASUBBLOCKS* DataSubBlocks_var;
public:
bool LZWMinimumCodeSize_exists = false;
bool DataSubBlocks_exists = false;
UBYTE& LZWMinimumCodeSize() {
assert_cond(LZWMinimumCodeSize_exists, "struct field LZWMinimumCodeSize does not exist");
return LZWMinimumCodeSize_var;
}
DATASUBBLOCKS& DataSubBlocks() {
assert_cond(DataSubBlocks_exists, "struct field DataSubBlocks does not exist");
return *DataSubBlocks_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
IMAGEDATA& operator () () { return *instances.back(); }
IMAGEDATA& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
IMAGEDATA(std::vector<IMAGEDATA*>& instances) : instances(instances) { instances.push_back(this); }
~IMAGEDATA() {
if (generated == 2)
return;
while (instances.size()) {
IMAGEDATA* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
IMAGEDATA* generate();
};
int IMAGEDATA::_parent_id = 0;
int IMAGEDATA::_index_start = 0;
class GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS {
std::vector<GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS*>& instances;
UBYTE Reserved_var : 3;
UBYTE DisposalMethod_var : 3;
UBYTE UserInputFlag_var : 1;
UBYTE TransparentColorFlag_var : 1;
public:
bool Reserved_exists = false;
bool DisposalMethod_exists = false;
bool UserInputFlag_exists = false;
bool TransparentColorFlag_exists = false;
UBYTE Reserved() {
assert_cond(Reserved_exists, "struct field Reserved does not exist");
return Reserved_var;
}
UBYTE DisposalMethod() {
assert_cond(DisposalMethod_exists, "struct field DisposalMethod does not exist");
return DisposalMethod_var;
}
UBYTE UserInputFlag() {
assert_cond(UserInputFlag_exists, "struct field UserInputFlag does not exist");
return UserInputFlag_var;
}
UBYTE TransparentColorFlag() {
assert_cond(TransparentColorFlag_exists, "struct field TransparentColorFlag does not exist");
return TransparentColorFlag_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS& operator () () { return *instances.back(); }
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS(std::vector<GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS*>& instances) : instances(instances) { instances.push_back(this); }
~GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS() {
if (generated == 2)
return;
while (instances.size()) {
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS* generate();
};
int GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS::_parent_id = 0;
int GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS::_index_start = 0;
class GRAPHICCONTROLSUBBLOCK {
std::vector<GRAPHICCONTROLSUBBLOCK*>& instances;
UBYTE BlockSize_var;
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS* PackedFields_var;
ushort DelayTime_var;
UBYTE TransparentColorIndex_var;
public:
bool BlockSize_exists = false;
bool PackedFields_exists = false;
bool DelayTime_exists = false;
bool TransparentColorIndex_exists = false;
UBYTE& BlockSize() {
assert_cond(BlockSize_exists, "struct field BlockSize does not exist");
return BlockSize_var;
}
GRAPHICCONTROLEXTENSION_DATASUBBLOCK_PACKEDFIELDS& PackedFields() {
assert_cond(PackedFields_exists, "struct field PackedFields does not exist");
return *PackedFields_var;
}
ushort& DelayTime() {
assert_cond(DelayTime_exists, "struct field DelayTime does not exist");
return DelayTime_var;
}
UBYTE& TransparentColorIndex() {
assert_cond(TransparentColorIndex_exists, "struct field TransparentColorIndex does not exist");
return TransparentColorIndex_var;
}
unsigned char generated = 0;
static int _parent_id;
static int _index_start;
int64 _startof = 0;
std::size_t _sizeof = 0;
GRAPHICCONTROLSUBBLOCK& operator () () { return *instances.back(); }
GRAPHICCONTROLSUBBLOCK& operator [] (int index) {
assert_cond((unsigned)(_index_start + index) < instances.size(), "instance index out of bounds");
return *instances[_index_start + index];
}
std::size_t array_size() {
return instances.size() - _index_start;
}
GRAPHICCONTROLSUBBLOCK(std::vector<GRAPHICCONTROLSUBBLOCK*>& instances) : instances(instances) { instances.push_back(this); }
~GRAPHICCONTROLSUBBLOCK() {
if (generated == 2)
return;
while (instances.size()) {
GRAPHICCONTROLSUBBLOCK* instance = instances.back();
instances.pop_back();
if (instance->generated == 2)
delete instance;
}
}
GRAPHICCONTROLSUBBLOCK* generate();
};
int GRAPHICCONTROLSUBBLOCK::_parent_id = 0;
int GRAPHICCONTROLSUBBLOCK::_index_start = 0;
class GRAPHICCONTROLEXTENSION {
std::vector<GRAPHICCONTROLEXTENSION*>& instances;
UBYTE ExtensionIntroducer_var;
UBYTE GraphicControlLabel_var;
GRAPHICCONTROLSUBBLOCK* GraphicControlSubBlock_var;
UBYTE BlockTerminator_var;
public:
bool ExtensionIntroducer_exists = false;
bool GraphicControlLabel_exists = false;
bool GraphicControlSubBlock_exists = false;
bool BlockTerminator_exists = false;
UBYTE& ExtensionIntroducer() {
assert_cond(ExtensionIntroducer_exists, "struct field ExtensionIntroducer does not exist");
return ExtensionIntroducer_var;
}
UBYTE& GraphicControlLabel() {
assert_cond(GraphicControlLabel_exists, "struct field GraphicControlLabel does not exist");