1#ifndef PACKING_BUFFER_H_
2#define PACKING_BUFFER_H_
33template <
typename WordType>
39 BufferReader(
const std::vector<uint8_t>& b) : buffer_{b}, i_word_{0} {}
46 operator bool() {
return (i_word_ < buffer_.size()); }
62 if (*
this) w =
next();
76 for (std::size_t i_byte{0}; i_byte < n_bytes_; i_byte++) {
77 w |= (buffer_.at(i_word_ + i_byte) << 8 * i_byte);
85 static const std::size_t n_bytes_{
sizeof(WordType)};
87 const std::vector<uint8_t>& buffer_;
This class is a helper class for reading the buffer stored in the raw data format.
BufferReader(const std::vector< uint8_t > &b)
Initialize a reader by wrapping a buffer to read.
BufferReader & operator>>(WordType &w)
Streaming operator We get the next word if we are still in the buffer.
WordType next()
Go to next word in buffer.