class mrpt::io::CStream
This base class is used to provide a unified interface to files,memory buffers,..Please see the derived classes.
This class is largely inspired by Borland VCL “TStream” class.
Apart of the “VCL like” methods, operators “>>” and “<<” have been defined so that simple types (int,bool,char,float,char *,std::string,…) can be directly written and read to and from any CStream easily. Please, it is recomendable to read CSerializable documentation also.
See also:
CFileStream, CMemoryStream,CSerializable
#include <mrpt/io/CStream.h> class CStream { public: // construction CStream(); // methods virtual size_t Read(void* Buffer, size_t Count) = 0; virtual size_t Write(const void* Buffer, size_t Count) = 0; virtual uint64_t getTotalBytesCount() const = 0; virtual uint64_t getPosition() const = 0; }; // direct descendants class CClientTCPSocket; class CInterfaceFTDI; class CSerialPort; class CFileGZInputStream; class CFileGZOutputStream; class CFileInputStream; class CFileOutputStream; class CFileStream; class CMemoryStream; class CPipeBaseEndPoint;
Construction
CStream()
Constructor.
Methods
virtual size_t Read(void* Buffer, size_t Count) = 0
Introduces a pure virtual method responsible for reading from the stream.
virtual size_t Write(const void* Buffer, size_t Count) = 0
Introduces a pure virtual method responsible for writing to the stream.
Write attempts to write up to Count bytes to Buffer, and returns the number of bytes actually written.
virtual uint64_t getTotalBytesCount() const = 0
Returns the total amount of bytes in the stream.
virtual uint64_t getPosition() const = 0
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.