MRPT
2.0.1
|
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 28 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 ()=default | |
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 ('' characters are ignored). More... | |
Used in CStream::Seek.
Enumerator | |
---|---|
sFromBeginning | |
sFromCurrent | |
sFromEnd |
Definition at line 32 of file io/CStream.h.
|
default |
|
virtualdefault |
bool CStream::getline | ( | std::string & | out_str | ) |
Reads from the stream until a '
' character is found ('' 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::CInterfaceFTDI, mrpt::comms::CSerialPort, mrpt::comms::CClientTCPSocket, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileStream, mrpt::io::CFileOutputStream, mrpt::io::CMemoryStream, mrpt::io::CFileGZInputStream, mrpt::io::CFileGZOutputStream, and mrpt::io::CFileInputStream.
|
pure virtual |
Returns the total amount of bytes in the stream.
Implemented in mrpt::comms::CInterfaceFTDI, mrpt::comms::CSerialPort, mrpt::comms::CClientTCPSocket, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileStream, mrpt::io::CFileGZOutputStream, mrpt::io::CMemoryStream, mrpt::io::CFileOutputStream, mrpt::io::CFileGZInputStream, and mrpt::io::CFileInputStream.
|
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 mrpt::system::os::vsnprintf().
Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel(), mrpt::apps::MonteCarloLocalization_Base::do_pf_localization(), printf_vector(), mrpt::apps::CGridMapAlignerApp::run(), mrpt::apps::RBPF_SLAM_App_Base::run(), and mrpt::apps::ICP_SLAM_App_Base::run().
|
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 102 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::CPipeWriteEndPoint, mrpt::comms::CInterfaceFTDI, mrpt::comms::CSerialPort, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileGZInputStream, mrpt::io::CFileOutputStream, mrpt::io::CFileGZOutputStream, mrpt::io::CFileInputStream, mrpt::comms::CClientTCPSocket, mrpt::io::CFileStream, and mrpt::io::CMemoryStream.
Referenced by mrpt::io::zip::decompress(), mrpt::maps::CPointsMapXYZI::loadFromKittiVelodyneFile(), 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 62 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::CPipeBaseEndPoint, mrpt::io::CFileStream, mrpt::io::CFileGZInputStream, mrpt::io::CFileGZOutputStream, mrpt::io::CMemoryStream, mrpt::io::CFileOutputStream, and mrpt::io::CFileInputStream.
|
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::CInterfaceFTDI, mrpt::comms::CSerialPort, mrpt::io::CPipeReadEndPoint, mrpt::io::CPipeBaseEndPoint, mrpt::io::CFileGZInputStream, mrpt::io::CFileOutputStream, mrpt::io::CFileGZOutputStream, mrpt::comms::CClientTCPSocket, mrpt::io::CFileInputStream, mrpt::io::CFileStream, and mrpt::io::CMemoryStream.
Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020 |