stream_reader.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_SERIALIZATION_STREAM_READER_H
00027 #define ODVA_ETHERNETIP_SERIALIZATION_STREAM_READER_H
00028 
00029 #include <stdexcept>
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/asio.hpp>
00032 
00033 #include "odva_ethernetip/serialization/reader.h"
00034 
00035 using boost::shared_ptr;
00036 using boost::asio::mutable_buffer;
00037 using boost::asio::buffer_cast;
00038 using boost::asio::buffer_size;
00039 using std::istream;
00040 
00041 namespace eip {
00042 namespace serialization {
00043 
00049 class StreamReader : public Reader
00050 {
00051 public:
00052 
00057   StreamReader(shared_ptr<istream> isp) : isp_(isp) { }
00058 
00064   void readBytes(void* buf, size_t n)
00065   {
00066     isp_->read((char*)buf, n);
00067   }
00068 
00074   void readBuffer(mutable_buffer buf)
00075   {
00076     readBytes(buffer_cast<void*>(buf), buffer_size(buf));
00077   }
00078 
00083   size_t getByteCount()
00084   {
00085     return isp_->tellg();
00086   }
00087 
00092   virtual void skip(size_t n)
00093   {
00094     isp_->seekg(n, std::ios_base::cur);
00095   }
00096 private:
00097   shared_ptr<istream> isp_;
00098 };
00099 
00100 } // namespace serialization
00101 } // namespace eip
00102 #endif  // ODVA_ETHERNETIP_SERIALIZATION_STREAM_READER_H


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Sat Jun 8 2019 20:21:23