Read an index at the given byte width
| 35 | |
| 36 | // Read an index at the given byte width |
| 37 | [[nodiscard]] uint32_t readIndex(const uint8_t* data, std::size_t row, uint8_t bytes) { |
| 38 | switch (bytes) { |
| 39 | case 1: { |
| 40 | uint8_t v = 0; |
| 41 | std::memcpy(&v, data + row, sizeof(v)); |
| 42 | return v; |
| 43 | } |
| 44 | case 2: { |
| 45 | uint16_t v = 0; |
| 46 | std::memcpy(&v, data + row * 2, sizeof(v)); |
| 47 | return v; |
| 48 | } |
| 49 | default: { |
| 50 | uint32_t v = 0; |
| 51 | std::memcpy(&v, data + row * 4, sizeof(v)); |
| 52 | return v; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | } // namespace |
| 58 |