1use super::*;
2
3#[derive(Default)]
4pub struct Table {
5 pub offset: usize,
6 pub len: usize,
7 pub width: usize,
8 pub columns: [Column; 6],
9}
10
11impl Table {
12 pub fn index_width(&self) -> usize {
13 if self.len < (1 << 16) {
14 2
15 } else {
16 4
17 }
18 }
19
20 pub fn set_columns(&mut self, a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) {
21 self.width = a + b + c + d + e + f;
22 self.columns[0] = Column::new(0, a);
23 if b != 0 {
24 self.columns[1] = Column::new(a, b);
25 }
26 if c != 0 {
27 self.columns[2] = Column::new(a + b, c);
28 }
29 if d != 0 {
30 self.columns[3] = Column::new(a + b + c, d);
31 }
32 if e != 0 {
33 self.columns[4] = Column::new(a + b + c + d, e);
34 }
35 if f != 0 {
36 self.columns[5] = Column::new(a + b + c + d + e, f);
37 }
38 }
39
40 pub fn set_data(&mut self, offset: &mut usize) {
41 if self.len != 0 {
42 let next = *offset + self.len * self.width;
43 self.offset = *offset;
44 *offset = next;
45 }
46 }
47}
48