stream_reader.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_SERIALIZATION_STREAM_READER_H
27 #define ODVA_ETHERNETIP_SERIALIZATION_STREAM_READER_H
28 
29 #include <stdexcept>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/asio.hpp>
32 
34 
35 using boost::shared_ptr;
36 using boost::asio::mutable_buffer;
37 using boost::asio::buffer_cast;
38 using boost::asio::buffer_size;
39 using std::istream;
40 
41 namespace eip {
42 namespace serialization {
43 
49 class StreamReader : public Reader
50 {
51 public:
52 
57  StreamReader(shared_ptr<istream> isp) : isp_(isp) { }
58 
64  void readBytes(void* buf, size_t n)
65  {
66  isp_->read((char*)buf, n);
67  }
68 
74  void readBuffer(mutable_buffer buf)
75  {
76  readBytes(buffer_cast<void*>(buf), buffer_size(buf));
77  }
78 
83  size_t getByteCount()
84  {
85  return isp_->tellg();
86  }
87 
92  virtual void skip(size_t n)
93  {
94  isp_->seekg(n, std::ios_base::cur);
95  }
96 private:
97  shared_ptr<istream> isp_;
98 };
99 
100 } // namespace serialization
101 } // namespace eip
102 #endif // ODVA_ETHERNETIP_SERIALIZATION_STREAM_READER_H
virtual void skip(size_t n)
Definition: stream_reader.h:92
Definition: connection.h:41
void readBuffer(mutable_buffer buf)
Definition: stream_reader.h:74
shared_ptr< istream > isp_
Definition: stream_reader.h:97
void readBytes(void *buf, size_t n)
Definition: stream_reader.h:64
StreamReader(shared_ptr< istream > isp)
Definition: stream_reader.h:57


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16