1 module barcode.types; 2 3 public import std.bitmanip : BitArray; 4 5 /// 6 struct BarCode 7 { 8 /// 9 size_t width; 10 /// 11 BitArray data; 12 /// 13 string type; 14 15 pure const 16 { 17 /// 18 bool opIndex(size_t x, size_t y) 19 { 20 if (0 <= x && x < width && 21 0 <= y && y < height) 22 return data[cast(uint)(y*width+x)]; 23 return false; 24 } 25 26 /// 27 bool opIndex(size_t i) 28 { 29 if (0 <= i && i < data.length) 30 return data[cast(uint)i]; 31 return false; 32 } 33 34 /// 35 auto height() { return data.length / width; } 36 } 37 } 38 39 /// 40 interface BarCodeEncoder 41 { 42 /// 43 BarCode encode(string str); 44 }