3 #include <boost/endian/conversion.hpp> 17 if(boost::asio::buffer_size(buffer) >=
bytesCount)
19 parse(buffer, outBinaryNav);
23 throw std::runtime_error(
24 "Not enough byes in buffer to parse this memory block");
29 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf,
double& res)
31 uint64_t bytes = *boost::asio::buffer_cast<
const uint64_t*>(buf);
32 boost::endian::big_to_native_inplace(bytes);
33 std::memcpy(&res, &bytes,
sizeof(
double));
34 buf = buf +
sizeof(double);
38 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf,
float& res)
40 uint32_t bytes = *boost::asio::buffer_cast<
const uint32_t*>(buf);
41 boost::endian::big_to_native_inplace(bytes);
42 std::memcpy(&res, &bytes,
sizeof(
float));
43 buf = buf +
sizeof(float);
47 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf, int32_t& res)
49 res = *boost::asio::buffer_cast<
const int32_t*>(buf);
50 boost::endian::big_to_native_inplace(res);
51 buf = buf +
sizeof(int32_t);
55 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf, uint64_t& res)
57 res = *boost::asio::buffer_cast<
const uint64_t*>(buf);
58 boost::endian::big_to_native_inplace(res);
59 buf = buf +
sizeof(uint64_t);
63 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf, uint32_t& res)
65 res = *boost::asio::buffer_cast<
const uint32_t*>(buf);
66 boost::endian::big_to_native_inplace(res);
67 buf = buf +
sizeof(uint32_t);
71 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf, uint16_t& res)
73 res = *boost::asio::buffer_cast<
const uint16_t*>(buf);
74 boost::endian::big_to_native_inplace(res);
75 buf = buf +
sizeof(uint16_t);
79 boost::asio::const_buffer&
operator>>(boost::asio::const_buffer& buf, uint8_t& res)
81 res = *boost::asio::buffer_cast<
const uint8_t*>(buf);
82 buf = buf +
sizeof(uint8_t);
void parse(boost::asio::const_buffer &buffer, const tBitMask &mask, Data::BinaryNav &outBinaryNav)
const size_t offsetInMask
std::bitset< 32 > tBitMask
boost::asio::const_buffer & operator>>(boost::asio::const_buffer &buf, std::array< uint8_t, N > &res)