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.
Definition at line 30 of file io/CStream.h.
#include <mrpt/io/CStream.h>
Public Types | |
enum | TSeekOrigin { sFromBeginning = 0, sFromCurrent = 1, sFromEnd = 2 } |
Used in CStream::Seek. More... | |
Public Member Functions | |
virtual size_t | Read (void *Buffer, size_t Count)=0 |
Introduces a pure virtual method responsible for reading from the stream. More... | |
virtual size_t | Write (const void *Buffer, size_t Count)=0 |
Introduces a pure virtual method responsible for writing to the stream. More... | |
CStream () | |
virtual | ~CStream () |
virtual size_t | ReadBufferImmediate (void *Buffer, size_t Count) |
Reads a block of bytes from the stream into Buffer, and returns the amound of bytes actually read, without waiting for more extra bytes to arrive (just those already enqued in the stream). More... | |
virtual uint64_t | Seek (int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning)=0 |
Introduces a pure virtual method for moving to a specified position in the streamed resource. More... | |
virtual uint64_t | getTotalBytesCount () const =0 |
Returns the total amount of bytes in the stream. More... | |
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. More... | |
virtual int | printf (const char *fmt,...) MRPT_printf_format_check(2 |
Writes a string to the stream in a textual form. More... | |
template<typename CONTAINER_TYPE > | |
virtual int void | printf_vector (const char *fmt, const CONTAINER_TYPE &V, char separator=',') |
Prints a vector in the format [A,B,C,...] using CStream::printf, and the fmt string for each vector element T . More... | |
bool | getline (std::string &out_str) |
Reads from the stream until a ' ' character is found ('\r' characters are ignored). More... | |
Used in CStream::Seek.
Enumerator | |
---|---|
sFromBeginning | |
sFromCurrent | |
sFromEnd |
Definition at line 34 of file io/CStream.h.
|
inline |
Definition at line 52 of file io/CStream.h.
|
virtual |
Definition at line 26 of file CStream.cpp.
bool CStream::getline | ( | std::string & | out_str | ) |
Reads from the stream until a '
' character is found ('\r' characters are ignored).
Definition at line 69 of file CStream.cpp.
|
pure virtual |
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.
Implemented in mrpt::comms::CSerialPort, mrpt::comms::CClientTCPSocket, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileStream, mrpt::io::CMemoryStream, mrpt::io::CFileOutputStream, mrpt::io::CFileGZInputStream, mrpt::io::CFileInputStream, mrpt::io::CFileGZOutputStream, and mrpt::comms::CInterfaceFTDI.
|
pure virtual |
Returns the total amount of bytes in the stream.
Implemented in mrpt::comms::CSerialPort, mrpt::comms::CClientTCPSocket, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileStream, mrpt::io::CMemoryStream, mrpt::io::CFileOutputStream, mrpt::io::CFileGZOutputStream, mrpt::io::CFileGZInputStream, mrpt::io::CFileInputStream, and mrpt::comms::CInterfaceFTDI.
|
virtual |
Writes a string to the stream in a textual form.
Definition at line 30 of file CStream.cpp.
References MRPT_END, MRPT_START, and vsnprintf.
Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel(), and printf_vector().
|
inline |
Prints a vector in the format [A,B,C,...] using CStream::printf, and the fmt string for each vector element T
.
CONTAINER_TYPE | can be any vector<T>, deque<T> or alike. |
Definition at line 104 of file io/CStream.h.
References printf().
Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel().
|
pure virtual |
Introduces a pure virtual method responsible for reading from the stream.
Implemented in mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileOutputStream, mrpt::io::CFileGZInputStream, mrpt::io::CFileInputStream, mrpt::io::CFileGZOutputStream, mrpt::comms::CClientTCPSocket, mrpt::io::CFileStream, mrpt::io::CMemoryStream, mrpt::io::CPipeWriteEndPoint, mrpt::comms::CInterfaceFTDI, and mrpt::comms::CSerialPort.
Referenced by mrpt::hwdrivers::CHokuyoURG::assureBufferHasBytes(), mrpt::io::zip::decompress(), mrpt::hwdrivers::CGPSInterface::doProcess(), fill_input_buffer(), mrpt::hwdrivers::CHokuyoURG::purgeBuffers(), and ReadBufferImmediate().
|
inlinevirtual |
Reads a block of bytes from the stream into Buffer, and returns the amound of bytes actually read, without waiting for more extra bytes to arrive (just those already enqued in the stream).
Note that this method will fallback to ReadBuffer() in most CStream classes but in some hardware-related classes.
std::exception | On any error, or if ZERO bytes are read. |
Reimplemented in mrpt::comms::CInterfaceFTDI.
Definition at line 64 of file io/CStream.h.
References Read().
|
pure virtual |
Introduces a pure virtual method for moving to a specified position in the streamed resource.
he Origin parameter indicates how to interpret the Offset parameter. Origin should be one of the following values:
Implemented in mrpt::io::CFileGZInputStream, mrpt::io::CFileGZOutputStream, mrpt::io::CMemoryStream, mrpt::io::CFileOutputStream, mrpt::io::CFileInputStream, mrpt::io::CFileStream, and mrpt::io::CPipeBaseEndPoint.
|
pure virtual |
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.
Implemented in mrpt::comms::CSerialPort, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileOutputStream, mrpt::comms::CClientTCPSocket, mrpt::io::CFileGZInputStream, mrpt::io::CFileInputStream, mrpt::io::CFileGZOutputStream, mrpt::io::CFileStream, mrpt::io::CMemoryStream, mrpt::comms::CInterfaceFTDI, and mrpt::io::CPipeReadEndPoint.
Referenced by mrpt::io::zip::compress(), empty_output_buffer(), mrpt::hwdrivers::CGPSInterface::OnConnectionEstablished(), mrpt::hwdrivers::CGPSInterface::OnConnectionShutdown(), mrpt::hwdrivers::CHokuyoURG::sendCmd(), mrpt::hwdrivers::CGPSInterface::sendCustomCommand(), and term_destination().
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST |