| 212 | /// Write a fixed length block prefix. |
| 213 | template <typename OffsetIterator, typename OutByteIter> |
| 214 | OutByteIter WriteBlockPrefix(OffsetIterator first, OffsetIterator last, OutByteIter out) const |
| 215 | { |
| 216 | constexpr std::size_t MAX_LENGTH = |
| 217 | std::numeric_limits<std::make_unsigned_t<ValueType>>::max(); |
| 218 | |
| 219 | auto index = 0; |
| 220 | std::array<ValueType, BLOCK_SIZE> prefix{}; |
| 221 | |
| 222 | for (OffsetIterator curr = first, next = std::next(first); curr != last; ++curr, ++next) |
| 223 | { |
| 224 | const std::uint32_t data_length = *next - *curr; |
| 225 | if (data_length > MAX_LENGTH) |
| 226 | throw util::exception( |
| 227 | std::format("too large data length {} > {}", data_length, MAX_LENGTH)); |
| 228 | |
| 229 | prefix[index++] = data_length; |
| 230 | } |
| 231 | |
| 232 | out = std::copy_n((const char *)prefix.data(), sizeof(ValueType) * BLOCK_SIZE, out); |
| 233 | return out; |
| 234 | } |
| 235 | |
| 236 | /// Advances the range to an item stored in the referenced block. |
| 237 | /// Input [first..last) is a range of the complete block data with prefix. |
no test coverage detected