39 BinParser(uint8_t* buffer,
size_t buf_len) : buf_pos_(buffer), buf_end_(buffer + buf_len), parent_(*this)
41 assert(buf_pos_ <= buf_end_);
45 : buf_pos_(parent.buf_pos_), buf_end_(parent.buf_pos_ + sub_len), parent_(parent)
47 assert(buf_pos_ <= buf_end_);
89 assert(buf_pos_ +
sizeof(T) <= buf_end_);
91 std::memcpy(&val, buf_pos_,
sizeof(T));
99 buf_pos_ +=
sizeof(T);
105 parse<uint64_t>(inner);
106 std::memcpy(&val, &inner,
sizeof(
double));
111 parse<uint32_t>(inner);
112 std::memcpy(&val, &inner,
sizeof(
float));
120 parse<uint8_t>(inner);
141 parse(val,
size_t(buf_end_ - buf_pos_));
144 void parse(std::string& val,
size_t len)
146 val.assign(reinterpret_cast<char*>(buf_pos_), len);
155 parse(val,
size_t(len));
158 template <
typename T,
size_t N>
161 for (
size_t i = 0; i < N; i++)
167 template <
typename T,
size_t N>
172 set = std::bitset<N>(val);
186 return bytes <= size_t(buf_end_ - buf_pos_);
188 template <
typename T>
201 LOG_DEBUG(
"BinParser: %p - %p (%zu bytes)", buf_pos_, buf_end_, buf_end_ - buf_pos_);
void parse(double3_t &val)
#define LOG_DEBUG(format,...)
int64_t decode(int64_t val)
void parse(std::string &val)
uint32_t decode(uint32_t val)
uint16_t decode(uint16_t val)
void parse(std::bitset< N > &set)
BinParser(BinParser &parent, size_t sub_len)
uint64_t decode(uint64_t val)
bool checkSize(size_t bytes)
int32_t decode(int32_t val)
void parse(std::string &val, size_t len)
int16_t decode(int16_t val)
void parse_remainder(std::string &val)
void parse(cartesian_coord_t &val)
void parse(std::array< T, N > &array)
BinParser(uint8_t *buffer, size_t buf_len)
void consume(size_t bytes)