Write an index in the given byte width
| 15 | |
| 16 | // Write an index in the given byte width |
| 17 | void writeIndex(RawBuffer& buf, uint32_t index, uint8_t bytes) { |
| 18 | switch (bytes) { |
| 19 | case 1: { |
| 20 | auto v = static_cast<uint8_t>(index); |
| 21 | buf.append(&v, sizeof(v)); |
| 22 | break; |
| 23 | } |
| 24 | case 2: { |
| 25 | auto v = static_cast<uint16_t>(index); |
| 26 | buf.append(&v, sizeof(v)); |
| 27 | break; |
| 28 | } |
| 29 | default: { |
| 30 | buf.append(&index, sizeof(index)); |
| 31 | break; |
| 32 | } |
| 33 | } |
| 34 | } |
| 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) { |
no test coverage detected