libqi-api
2.0.6.8
|
00001 #pragma once 00002 /* 00003 ** Copyright (C) 2012 Aldebaran Robotics 00004 ** See COPYING for the license 00005 */ 00006 00007 #ifndef _QI_BUFFERREADER_HPP_ 00008 #define _QI_BUFFERREADER_HPP_ 00009 00010 #include <qi/buffer.hpp> 00011 00012 namespace qi { 00013 00015 class QI_API BufferReader 00016 { 00017 public: 00019 explicit BufferReader(const Buffer& buf); 00021 ~BufferReader(); 00023 size_t read(void *data, size_t length); 00024 00026 void *read(size_t offset); 00028 bool seek(size_t offset); 00030 void *peek(size_t offset) const; 00031 00033 bool hasSubBuffer() const; 00035 const Buffer& subBuffer(); 00037 size_t position() const; 00038 00039 private: 00040 Buffer _buffer; 00041 size_t _cursor; 00042 size_t _subCursor; // position in sub-buffers 00043 }; 00044 } 00045 00046 #endif // _QI_BUFFERREADER_HPP_