-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrekordbox_pdb.h
1875 lines (1470 loc) · 50.6 KB
/
rekordbox_pdb.h
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
#ifndef REKORDBOX_PDB_H_
#define REKORDBOX_PDB_H_
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "kaitaistruct.h"
#include <stdint.h>
#include <vector>
#if KAITAI_STRUCT_VERSION < 9000L
#error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required"
#endif
/**
* This is a relational database format designed to be efficiently used
* by very low power devices (there were deployments on 16 bit devices
* with 32K of RAM). Today you are most likely to encounter it within
* the Pioneer Professional DJ ecosystem, because it is the format that
* their rekordbox software uses to write USB and SD media which can be
* mounted in DJ controllers and used to play and mix music.
*
* It has been reverse-engineered to facilitate sophisticated
* integrations with light and laser shows, videos, and other musical
* instruments, by supporting deep knowledge of what is playing and
* what is coming next through monitoring the network communications of
* the players.
*
* The file is divided into fixed-size blocks. The first block has a
* header that establishes the block size, and lists the tables
* available in the database, identifying their types and the index of
* the first of the series of linked pages that make up that table.
*
* Each table is made up of a series of rows which may be spread across
* any number of pages. The pages start with a header describing the
* page and linking to the next page. The rest of the page is used as a
* heap: rows are scattered around it, and located using an index
* structure that builds backwards from the end of the page. Each row
* of a given type has a fixed size structure which links to any
* variable-sized strings by their offsets within the page.
*
* As changes are made to the table, some records may become unused,
* and there may be gaps within the heap that are too small to be used
* by other data. There is a bit map in the row index that identifies
* which rows are actually present. Rows that are not present must be
* ignored: they do not contain valid (or even necessarily well-formed)
* data.
*
* The majority of the work in reverse-engineering this format was
* performed by @henrybetts and @flesniak, for which I am hugely
* grateful. @GreyCat helped me learn the intricacies (and best
* practices) of Kaitai far faster than I would have managed on my own.
* \sa https://github.com/Deep-Symmetry/crate-digger/blob/master/doc/Analysis.pdf Source
*/
class rekordbox_pdb_t : public kaitai::kstruct {
public:
class device_sql_string_t;
class history_playlist_row_t;
class playlist_tree_row_t;
class color_row_t;
class device_sql_short_ascii_t;
class album_row_t;
class page_t;
class row_group_t;
class genre_row_t;
class history_entry_row_t;
class artwork_row_t;
class device_sql_long_ascii_t;
class artist_row_t;
class page_ref_t;
class track_row_t;
class key_row_t;
class playlist_entry_row_t;
class label_row_t;
class device_sql_long_utf16le_t;
class table_t;
class row_ref_t;
enum page_type_t {
PAGE_TYPE_TRACKS = 0,
PAGE_TYPE_GENRES = 1,
PAGE_TYPE_ARTISTS = 2,
PAGE_TYPE_ALBUMS = 3,
PAGE_TYPE_LABELS = 4,
PAGE_TYPE_KEYS = 5,
PAGE_TYPE_COLORS = 6,
PAGE_TYPE_PLAYLIST_TREE = 7,
PAGE_TYPE_PLAYLIST_ENTRIES = 8,
PAGE_TYPE_UNKNOWN_9 = 9,
PAGE_TYPE_UNKNOWN_10 = 10,
PAGE_TYPE_HISTORY_PLAYLISTS = 11,
PAGE_TYPE_HISTORY_ENTRIES = 12,
PAGE_TYPE_ARTWORK = 13,
PAGE_TYPE_UNKNOWN_14 = 14,
PAGE_TYPE_UNKNOWN_15 = 15,
PAGE_TYPE_COLUMNS = 16,
PAGE_TYPE_UNKNOWN_17 = 17,
PAGE_TYPE_UNKNOWN_18 = 18,
PAGE_TYPE_HISTORY = 19
};
rekordbox_pdb_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~rekordbox_pdb_t();
/**
* A variable length string which can be stored in a variety of
* different encodings.
*/
class device_sql_string_t : public kaitai::kstruct {
public:
device_sql_string_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~device_sql_string_t();
private:
uint8_t m_length_and_kind;
kaitai::kstruct* m_body;
rekordbox_pdb_t* m__root;
kaitai::kstruct* m__parent;
public:
/**
* Mangled length of an ordinary ASCII string if odd, or a flag
* indicating another encoding with a longer length value to
* follow.
*/
uint8_t length_and_kind() const { return m_length_and_kind; }
kaitai::kstruct* body() const { return m_body; }
rekordbox_pdb_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; }
};
/**
* A row that holds a history playlist ID and name, linking to
* the track IDs captured during a performance on the player.
*/
class history_playlist_row_t : public kaitai::kstruct {
public:
history_playlist_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~history_playlist_row_t();
private:
uint32_t m_id;
device_sql_string_t* m_name;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* The unique identifier by which this history playlist can
* be requested.
*/
uint32_t id() const { return m_id; }
/**
* The variable-length string naming the playlist.
*/
device_sql_string_t* name() const { return m_name; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* A row that holds a playlist name, ID, indication of whether it
* is an ordinary playlist or a folder of other playlists, a link
* to its parent folder, and its sort order.
*/
class playlist_tree_row_t : public kaitai::kstruct {
public:
playlist_tree_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~playlist_tree_row_t();
private:
bool f_is_folder;
bool m_is_folder;
public:
bool is_folder();
private:
uint32_t m_parent_id;
std::string m__unnamed1;
uint32_t m_sort_order;
uint32_t m_id;
uint32_t m_raw_is_folder;
device_sql_string_t* m_name;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* The ID of the `playlist_tree_row` in which this one can be
* found, or `0` if this playlist exists at the root level.
*/
uint32_t parent_id() const { return m_parent_id; }
std::string _unnamed1() const { return m__unnamed1; }
/**
* The order in which the entries of this playlist are sorted.
*/
uint32_t sort_order() const { return m_sort_order; }
/**
* The unique identifier by which this playlist or folder can
* be requested and linked from other rows.
*/
uint32_t id() const { return m_id; }
/**
* Has a non-zero value if this is actually a folder rather
* than a playlist.
*/
uint32_t raw_is_folder() const { return m_raw_is_folder; }
/**
* The variable-length string naming the playlist.
*/
device_sql_string_t* name() const { return m_name; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* A row that holds a color name and the associated ID.
*/
class color_row_t : public kaitai::kstruct {
public:
color_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~color_row_t();
private:
std::string m__unnamed0;
uint16_t m_id;
uint8_t m__unnamed2;
device_sql_string_t* m_name;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
std::string _unnamed0() const { return m__unnamed0; }
/**
* The unique identifier by which this color can be requested
* and linked from other rows (such as tracks).
*/
uint16_t id() const { return m_id; }
uint8_t _unnamed2() const { return m__unnamed2; }
/**
* The variable-length string naming the color.
*/
device_sql_string_t* name() const { return m_name; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* An ASCII-encoded string up to 127 bytes long.
*/
class device_sql_short_ascii_t : public kaitai::kstruct {
public:
device_sql_short_ascii_t(uint8_t p_length_and_kind, kaitai::kstream* p__io, rekordbox_pdb_t::device_sql_string_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~device_sql_short_ascii_t();
private:
bool f_length;
int32_t m_length;
public:
/**
* the length extracted of the entire device_sql_short_ascii type
*/
int32_t length();
private:
std::string m_text;
uint8_t m_length_and_kind;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::device_sql_string_t* m__parent;
public:
/**
* The content of the string.
*/
std::string text() const { return m_text; }
/**
* Contains the actual length, incremented, doubled, and
* incremented again. Go figure.
*/
uint8_t length_and_kind() const { return m_length_and_kind; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::device_sql_string_t* _parent() const { return m__parent; }
};
/**
* A row that holds an album name and ID.
*/
class album_row_t : public kaitai::kstruct {
public:
album_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~album_row_t();
private:
bool f_name;
device_sql_string_t* m_name;
public:
/**
* The name of this album.
*/
device_sql_string_t* name();
private:
uint16_t m__unnamed0;
uint16_t m_index_shift;
uint32_t m__unnamed2;
uint32_t m_artist_id;
uint32_t m_id;
uint32_t m__unnamed5;
uint8_t m__unnamed6;
uint8_t m_ofs_name;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* Some kind of magic word? Usually 0x80, 0x00.
*/
uint16_t _unnamed0() const { return m__unnamed0; }
/**
* TODO name from @flesniak, but what does it mean?
*/
uint16_t index_shift() const { return m_index_shift; }
uint32_t _unnamed2() const { return m__unnamed2; }
/**
* Identifies the artist associated with the album.
*/
uint32_t artist_id() const { return m_artist_id; }
/**
* The unique identifier by which this album can be requested
* and linked from other rows (such as tracks).
*/
uint32_t id() const { return m_id; }
uint32_t _unnamed5() const { return m__unnamed5; }
/**
* @flesniak says: "alwayx 0x03, maybe an unindexed empty string"
*/
uint8_t _unnamed6() const { return m__unnamed6; }
/**
* The location of the variable-length name string, relative to
* the start of this row.
*/
uint8_t ofs_name() const { return m_ofs_name; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* A table page, consisting of a short header describing the
* content of the page and linking to the next page, followed by a
* heap in which row data is found. At the end of the page there is
* an index which locates all rows present in the heap via their
* offsets past the end of the page header.
*/
class page_t : public kaitai::kstruct {
public:
page_t(kaitai::kstream* p__io, rekordbox_pdb_t::page_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~page_t();
private:
bool f_num_rows;
uint16_t m_num_rows;
public:
/**
* The number of rows on this page (controls the number of row
* index entries there are, but some of those may not be marked
* as present in the table due to deletion).
*/
uint16_t num_rows();
private:
bool f_num_groups;
int32_t m_num_groups;
public:
/**
* The number of row groups that are present in the index. Each
* group can hold up to sixteen rows. All but the final one
* will hold sixteen rows.
*/
int32_t num_groups();
private:
bool f_row_groups;
std::vector<row_group_t*>* m_row_groups;
bool n_row_groups;
public:
bool _is_null_row_groups() { row_groups(); return n_row_groups; };
private:
public:
/**
* The actual row groups making up the row index. Each group
* can hold up to sixteen rows. Non-data pages do not have
* actual rows, and attempting to parse them can crash.
*/
std::vector<row_group_t*>* row_groups();
private:
bool f_heap_pos;
int32_t m_heap_pos;
public:
int32_t heap_pos();
private:
bool f_is_data_page;
bool m_is_data_page;
public:
bool is_data_page();
private:
std::string m_gap;
uint32_t m_page_index;
page_type_t m_type;
page_ref_t* m_next_page;
uint32_t m__unnamed4;
std::string m__unnamed5;
uint8_t m_num_rows_small;
uint8_t m__unnamed7;
uint8_t m__unnamed8;
uint8_t m_page_flags;
uint16_t m_free_size;
uint16_t m_used_size;
uint16_t m__unnamed12;
uint16_t m_num_rows_large;
uint16_t m__unnamed14;
uint16_t m__unnamed15;
std::string m_heap;
bool n_heap;
public:
bool _is_null_heap() { heap(); return n_heap; };
private:
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::page_ref_t* m__parent;
public:
/**
* Only exposed until
* https://github.com/kaitai-io/kaitai_struct/issues/825 can be
* fixed.
*/
std::string gap() const { return m_gap; }
/**
* Matches the index we used to look up the page, sanity check?
*/
uint32_t page_index() const { return m_page_index; }
/**
* Identifies the type of information stored in the rows of this page.
*/
page_type_t type() const { return m_type; }
/**
* Index of the next page containing this type of rows. Points past
* the end of the file if there are no more.
*/
page_ref_t* next_page() const { return m_next_page; }
/**
* @flesniak said: "sequence number (0->1: 8->13, 1->2: 22, 2->3: 27)"
*/
uint32_t _unnamed4() const { return m__unnamed4; }
std::string _unnamed5() const { return m__unnamed5; }
/**
* Holds the value used for `num_rows` (see below) unless
* `num_rows_large` is larger (but not equal to `0x1fff`). This
* seems like some strange mechanism to deal with the fact that
* lots of tiny entries, such as are found in the
* `playlist_entries` table, are too big to count with a single
* byte. But why not just always use `num_rows_large`, then?
*/
uint8_t num_rows_small() const { return m_num_rows_small; }
/**
* @flesniak said: "a bitmask (1st track: 32)"
*/
uint8_t _unnamed7() const { return m__unnamed7; }
/**
* @flesniak said: "often 0, sometimes larger, esp. for pages
* with high real_entry_count (e.g. 12 for 101 entries)"
*/
uint8_t _unnamed8() const { return m__unnamed8; }
/**
* @flesniak said: "strange pages: 0x44, 0x64; otherwise seen: 0x24, 0x34"
*/
uint8_t page_flags() const { return m_page_flags; }
/**
* Unused space (in bytes) in the page heap, excluding the row
* index at end of page.
*/
uint16_t free_size() const { return m_free_size; }
/**
* The number of bytes that are in use in the page heap.
*/
uint16_t used_size() const { return m_used_size; }
/**
* @flesniak said: "(0->1: 2)"
*/
uint16_t _unnamed12() const { return m__unnamed12; }
/**
* Holds the value used for `num_rows` (as described above)
* when that is too large to fit into `num_rows_small`, and
* that situation seems to be indicated when this value is
* larger than `num_rows_small`, but not equal to `0x1fff`.
* This seems like some strange mechanism to deal with the fact
* that lots of tiny entries, such as are found in the
* `playlist_entries` table, are too big to count with a single
* byte. But why not just always use this value, then?
*/
uint16_t num_rows_large() const { return m_num_rows_large; }
/**
* @flesniak said: "1004 for strange blocks, 0 otherwise"
*/
uint16_t _unnamed14() const { return m__unnamed14; }
/**
* @flesniak said: "always 0 except 1 for history pages, num
* entries for strange pages?"
*/
uint16_t _unnamed15() const { return m__unnamed15; }
std::string heap() const { return m_heap; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::page_ref_t* _parent() const { return m__parent; }
};
/**
* A group of row indices, which are built backwards from the end
* of the page. Holds up to sixteen row offsets, along with a bit
* mask that indicates whether each row is actually present in the
* table.
*/
class row_group_t : public kaitai::kstruct {
public:
row_group_t(uint16_t p_group_index, kaitai::kstream* p__io, rekordbox_pdb_t::page_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~row_group_t();
private:
bool f_base;
int32_t m_base;
public:
/**
* The starting point of this group of row indices.
*/
int32_t base();
private:
bool f_row_present_flags;
uint16_t m_row_present_flags;
public:
/**
* Each bit specifies whether a particular row is present. The
* low order bit corresponds to the first row in this index,
* whose offset immediately precedes these flag bits. The
* second bit corresponds to the row whose offset precedes
* that, and so on.
*/
uint16_t row_present_flags();
private:
bool f_rows;
std::vector<row_ref_t*>* m_rows;
public:
/**
* The row offsets in this group.
*/
std::vector<row_ref_t*>* rows();
private:
uint16_t m_group_index;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::page_t* m__parent;
public:
/**
* Identifies which group is being generated. They build backwards
* from the end of the page.
*/
uint16_t group_index() const { return m_group_index; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::page_t* _parent() const { return m__parent; }
};
/**
* A row that holds a genre name and the associated ID.
*/
class genre_row_t : public kaitai::kstruct {
public:
genre_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~genre_row_t();
private:
uint32_t m_id;
device_sql_string_t* m_name;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* The unique identifier by which this genre can be requested
* and linked from other rows (such as tracks).
*/
uint32_t id() const { return m_id; }
/**
* The variable-length string naming the genre.
*/
device_sql_string_t* name() const { return m_name; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* A row that associates a track with a position in a history playlist.
*/
class history_entry_row_t : public kaitai::kstruct {
public:
history_entry_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~history_entry_row_t();
private:
uint32_t m_track_id;
uint32_t m_playlist_id;
uint32_t m_entry_index;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* The track found at this position in the playlist.
*/
uint32_t track_id() const { return m_track_id; }
/**
* The history playlist to which this entry belongs.
*/
uint32_t playlist_id() const { return m_playlist_id; }
/**
* The position within the playlist represented by this entry.
*/
uint32_t entry_index() const { return m_entry_index; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* A row that holds the path to an album art image file and the
* associated artwork ID.
*/
class artwork_row_t : public kaitai::kstruct {
public:
artwork_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~artwork_row_t();
private:
uint32_t m_id;
device_sql_string_t* m_path;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* The unique identifier by which this art can be requested
* and linked from other rows (such as tracks).
*/
uint32_t id() const { return m_id; }
/**
* The variable-length file path string at which the art file
* can be found.
*/
device_sql_string_t* path() const { return m_path; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* An ASCII-encoded string preceded by a two-byte length field in a four-byte header.
*/
class device_sql_long_ascii_t : public kaitai::kstruct {
public:
device_sql_long_ascii_t(kaitai::kstream* p__io, rekordbox_pdb_t::device_sql_string_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~device_sql_long_ascii_t();
private:
uint16_t m_length;
uint8_t m__unnamed1;
std::string m_text;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::device_sql_string_t* m__parent;
public:
/**
* Contains the length of the string in bytes.
*/
uint16_t length() const { return m_length; }
uint8_t _unnamed1() const { return m__unnamed1; }
/**
* The content of the string.
*/
std::string text() const { return m_text; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::device_sql_string_t* _parent() const { return m__parent; }
};
/**
* A row that holds an artist name and ID.
*/
class artist_row_t : public kaitai::kstruct {
public:
artist_row_t(kaitai::kstream* p__io, rekordbox_pdb_t::row_ref_t* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~artist_row_t();
private:
bool f_ofs_name_far;
uint16_t m_ofs_name_far;
bool n_ofs_name_far;
public:
bool _is_null_ofs_name_far() { ofs_name_far(); return n_ofs_name_far; };
private:
public:
/**
* For names that might be further than 0xff bytes from the
* start of this row, this holds a two-byte offset, and is
* signalled by the subtype value.
*/
uint16_t ofs_name_far();
private:
bool f_name;
device_sql_string_t* m_name;
public:
/**
* The name of this artist.
*/
device_sql_string_t* name();
private:
uint16_t m_subtype;
uint16_t m_index_shift;
uint32_t m_id;
uint8_t m__unnamed3;
uint8_t m_ofs_name_near;
rekordbox_pdb_t* m__root;
rekordbox_pdb_t::row_ref_t* m__parent;
public:
/**
* Usually 0x60, but 0x64 means we have a long name offset
* embedded in the row.
*/
uint16_t subtype() const { return m_subtype; }
/**
* TODO name from @flesniak, but what does it mean?
*/
uint16_t index_shift() const { return m_index_shift; }
/**
* The unique identifier by which this artist can be requested
* and linked from other rows (such as tracks).
*/
uint32_t id() const { return m_id; }
/**
* @flesniak says: "always 0x03, maybe an unindexed empty string"
*/
uint8_t _unnamed3() const { return m__unnamed3; }
/**
* The location of the variable-length name string, relative to
* the start of this row, unless subtype is 0x64.
*/
uint8_t ofs_name_near() const { return m_ofs_name_near; }
rekordbox_pdb_t* _root() const { return m__root; }
rekordbox_pdb_t::row_ref_t* _parent() const { return m__parent; }
};
/**
* An index which points to a table page (its offset can be found
* by multiplying the index by the `page_len` value in the file
* header). This type allows the linked page to be lazy loaded.
*/
class page_ref_t : public kaitai::kstruct {
public:
page_ref_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, rekordbox_pdb_t* p__root = 0);
private:
void _read();
void _clean_up();
public:
~page_ref_t();
private:
bool f_body;
page_t* m_body;
public:
/**
* When referenced, loads the specified page and parses its
* contents appropriately for the type of data it contains.
*/
page_t* body();
private:
uint32_t m_index;
rekordbox_pdb_t* m__root;
kaitai::kstruct* m__parent;
std::string m__raw_body;
kaitai::kstream* m__io__raw_body;