26 #ifndef ODVA_ETHERNETIP_SERIALIZATION_BUFFER_READER_H 27 #define ODVA_ETHERNETIP_SERIALIZATION_BUFFER_READER_H 30 #include <boost/asio.hpp> 35 using boost::asio::buffer;
36 using boost::asio::mutable_buffer;
37 using boost::asio::buffer_size;
40 namespace serialization {
74 return boost::asio::buffer_cast<
void*>(
readBuffer(n));
85 if (buffer_size(
buf_) < n)
87 throw std::length_error(
"Buffer too small to deserialize value");
89 mutable_buffer b = buffer(
buf_, n);
104 size_t n = buffer_size(buf);
105 if (buffer_size(
buf_) < n)
107 throw std::length_error(
"Buffer too small to deserialize value");
109 boost::asio::buffer_copy(buf,
buf_);
130 if (buffer_size(
buf_) < n)
132 throw std::length_error(
"End of buffer reached skipping forward");
144 #endif // ODVA_ETHERNETIP_SERIALIZATION_BUFFER_READER_H virtual void readBuffer(mutable_buffer buf)
BufferReader(mutable_buffer buf)
virtual size_t getByteCount()
virtual void * readBytes(size_t n)
virtual mutable_buffer readBuffer(size_t n)
virtual void skip(size_t n)
virtual void readBytes(void *buf, size_t n)