#include <mrpt/utils/CStream.h>
Public Types | |
enum | TSeekOrigin { sFromBeginning = 0, sFromCurrent = 1, sFromEnd = 2 } |
Used in CStream::Seek. More... | |
Public Member Functions | |
CStream () | |
virtual | ~CStream () |
size_t | ReadBuffer (void *Buffer, size_t Count) |
Reads a block of bytes from the stream into Buffer, and returns the amound of bytes actually read. | |
void | WriteBuffer (const void *Buffer, size_t Count) |
Writes a block of bytes to the stream from Buffer. | |
size_t | CopyFrom (CStream *Source, size_t Count) |
Copies a specified number of bytes from one stream to another. | |
virtual size_t | Seek (long Offset, CStream::TSeekOrigin Origin=sFromBeginning)=0 |
Introduces a pure virtual method for moving to a specified position in the streamed resource. | |
virtual size_t | getTotalBytesCount ()=0 |
Returns the total amount of bytes in the stream. | |
virtual size_t | getPosition ()=0 |
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one. | |
CStream & | operator<< (const CSerializablePtr &pObj) |
Write operator for objects. | |
CStream & | operator<< (const CSerializable &obj) |
Write operator for objects. | |
CStream & | operator>> (CSerializablePtr &pObj) |
Read operator for objects. | |
CStream & | operator>> (CSerializable &obj) |
Read operator for objects. | |
void | WriteObject (const CSerializable *o) |
Writes an object to the stream. | |
CSerializablePtr | ReadObject () |
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the object. | |
void | ReadObject (CSerializable *existingObj) |
Reads an object from stream, where its class must be the same as the supplied object, where the loaded object will be stored in. | |
virtual int | printf (const char *fmt,...) MRPT_printf_format_check(2 |
Writes a string to the stream in a textual form. | |
template<typename T > | |
virtual int void | printf_vector (const char *fmt, const std::vector< T > &V) |
Prints a vector in the format [A,B,C,. | |
Protected Member Functions | |
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. |
.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 56 of file CStream.h.
Used in CStream::Seek.
virtual mrpt::utils::CStream::~CStream | ( | ) | [virtual] |
size_t mrpt::utils::CStream::CopyFrom | ( | CStream * | Source, | |
size_t | Count | |||
) |
Copies a specified number of bytes from one stream to another.
virtual size_t mrpt::utils::CStream::getPosition | ( | ) | [pure virtual] |
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.
Implemented in mrpt::hwdrivers::CInterfaceFTDI, mrpt::hwdrivers::CSerialPort, mrpt::utils::CClientTCPSocket, mrpt::utils::CFileGZInputStream, mrpt::utils::CFileInputStream, mrpt::utils::CFileOutputStream, mrpt::utils::CFileStream, mrpt::utils::CMemoryStream, and mrpt::utils::CStdOutStream.
virtual size_t mrpt::utils::CStream::getTotalBytesCount | ( | ) | [pure virtual] |
Returns the total amount of bytes in the stream.
Implemented in mrpt::hwdrivers::CInterfaceFTDI, mrpt::hwdrivers::CSerialPort, mrpt::utils::CClientTCPSocket, mrpt::utils::CFileGZInputStream, mrpt::utils::CFileInputStream, mrpt::utils::CFileOutputStream, mrpt::utils::CFileStream, mrpt::utils::CMemoryStream, and mrpt::utils::CStdOutStream.
CStream& mrpt::utils::CStream::operator<< | ( | const CSerializable & | obj | ) |
Write operator for objects.
CStream& mrpt::utils::CStream::operator<< | ( | const CSerializablePtr & | pObj | ) |
Write operator for objects.
CStream& mrpt::utils::CStream::operator>> | ( | CSerializable & | obj | ) |
Read operator for objects.
CStream& mrpt::utils::CStream::operator>> | ( | CSerializablePtr & | pObj | ) |
Read operator for objects.
virtual int mrpt::utils::CStream::printf | ( | const char * | fmt, | |
... | ||||
) | [virtual] |
virtual int void mrpt::utils::CStream::printf_vector | ( | const char * | fmt, | |
const std::vector< T > & | V | |||
) | [inline] |
Prints a vector in the format [A,B,C,.
..] using CStream::printf, and the fmt string for each vector element.
virtual size_t mrpt::utils::CStream::Read | ( | void * | Buffer, | |
size_t | Count | |||
) | [protected, pure virtual] |
Introduces a pure virtual method responsible for reading from the stream.
Implemented in mrpt::hwdrivers::CInterfaceFTDI, mrpt::hwdrivers::CSerialPort, mrpt::utils::CClientTCPSocket, mrpt::utils::CFileGZInputStream, mrpt::utils::CFileInputStream, mrpt::utils::CFileOutputStream, mrpt::utils::CFileStream, mrpt::utils::CMemoryStream, and mrpt::utils::CStdOutStream.
size_t mrpt::utils::CStream::ReadBuffer | ( | void * | Buffer, | |
size_t | Count | |||
) |
Reads a block of bytes from the stream into Buffer, and returns the amound of bytes actually read.
std::exception | On any error, or if ZERO bytes are read. |
void mrpt::utils::CStream::ReadObject | ( | CSerializable * | existingObj | ) |
Reads an object from stream, where its class must be the same as the supplied object, where the loaded object will be stored in.
std::exception | On I/O error or different class found. | |
mrpt::utils::CExceptionEOF | On an End-Of-File condition found at a correct place: an EOF that abruptly finishes in the middle of one object raises a plain std::exception instead. |
CSerializablePtr mrpt::utils::CStream::ReadObject | ( | ) |
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the object.
std::exception | On I/O error or undefined class. | |
mrpt::utils::CExceptionEOF | On an End-Of-File condition found at a correct place: an EOF that abruptly finishes in the middle of one object raises a plain std::exception instead. |
virtual size_t mrpt::utils::CStream::Seek | ( | long | Offset, | |
CStream::TSeekOrigin | Origin = sFromBeginning | |||
) | [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::hwdrivers::CInterfaceFTDI, mrpt::hwdrivers::CSerialPort, mrpt::utils::CClientTCPSocket, mrpt::utils::CFileGZInputStream, mrpt::utils::CFileInputStream, mrpt::utils::CFileOutputStream, mrpt::utils::CFileStream, mrpt::utils::CMemoryStream, and mrpt::utils::CStdOutStream.
virtual size_t mrpt::utils::CStream::Write | ( | const void * | Buffer, | |
size_t | Count | |||
) | [protected, 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::hwdrivers::CInterfaceFTDI, mrpt::hwdrivers::CSerialPort, mrpt::utils::CClientTCPSocket, mrpt::utils::CFileGZInputStream, mrpt::utils::CFileInputStream, mrpt::utils::CFileOutputStream, mrpt::utils::CFileStream, mrpt::utils::CMemoryStream, and mrpt::utils::CStdOutStream.
void mrpt::utils::CStream::WriteBuffer | ( | const void * | Buffer, | |
size_t | Count | |||
) |
Writes a block of bytes to the stream from Buffer.
std::exception | On any error |
void mrpt::utils::CStream::WriteObject | ( | const CSerializable * | o | ) |
Writes an object to the stream.
Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Thu Feb 26 02:19:01 EST 2009 |