MRPT
1.9.9
|
Transparently opens a compressed "gz" file and reads uncompressed data from it.
If the file is not a .gz file, it silently reads data from the file. This class requires compiling MRPT with wxWidgets. If wxWidgets is not available then the class is actually mapped to the standard CFileInputStream
Definition at line 24 of file io/CFileGZInputStream.h.
#include <mrpt/io/CFileGZInputStream.h>
Public Types | |
enum | TSeekOrigin { sFromBeginning = 0, sFromCurrent = 1, sFromEnd = 2 } |
Used in CStream::Seek. More... | |
Public Member Functions | |
CFileGZInputStream () | |
Constructor without open. More... | |
CFileGZInputStream (const std::string &fileName) | |
Constructor and open. More... | |
CFileGZInputStream (const CFileGZInputStream &)=delete | |
CFileGZInputStream & | operator= (const CFileGZInputStream &)=delete |
virtual | ~CFileGZInputStream () |
Dtor. More... | |
bool | open (const std::string &fileName) |
Opens the file for read. More... | |
void | close () |
Closes the file. More... | |
bool | fileOpenCorrectly () const |
Returns true if the file was open without errors. More... | |
bool | is_open () |
Returns true if the file was open without errors. More... | |
bool | checkEOF () |
Will be true if EOF has been already reached. More... | |
uint64_t | getTotalBytesCount () const override |
Method for getting the total number of compressed bytes of in the file (the physical size of the compressed file). More... | |
uint64_t | getPosition () const override |
Method for getting the current cursor position in the compressed, where 0 is the first byte and TotalBytesCount-1 the last one. More... | |
uint64_t | Seek (int64_t, CStream::TSeekOrigin=sFromBeginning) override |
This method is not implemented in this class. More... | |
size_t | Read (void *Buffer, size_t Count) override |
Introduces a pure virtual method responsible for reading from the stream. More... | |
size_t | Write (const void *Buffer, size_t Count) override |
Introduces a pure virtual method responsible for writing to the stream. More... | |
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 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... | |
Private Attributes | |
void * | m_f |
uint64_t | m_file_size |
Compressed file size. More... | |
|
inherited |
Used in CStream::Seek.
Enumerator | |
---|---|
sFromBeginning | |
sFromCurrent | |
sFromEnd |
Definition at line 32 of file io/CStream.h.
CFileGZInputStream::CFileGZInputStream | ( | ) |
Constructor without open.
Definition at line 35 of file CFileGZInputStream.cpp.
CFileGZInputStream::CFileGZInputStream | ( | const std::string & | fileName | ) |
Constructor and open.
fileName | The file to be open in this stream |
std::exception | If there's an error opening the file. |
Definition at line 28 of file CFileGZInputStream.cpp.
References MRPT_END, MRPT_START, and open().
|
delete |
|
virtual |
bool CFileGZInputStream::checkEOF | ( | ) |
Will be true if EOF has been already reached.
Definition at line 100 of file CFileGZInputStream.cpp.
References m_f, and THE_GZFILE.
void CFileGZInputStream::close | ( | ) |
Closes the file.
Definition at line 54 of file CFileGZInputStream.cpp.
References m_f, and THE_GZFILE.
Referenced by mrpt::pbmap::PbMap::loadPbMap(), and ~CFileGZInputStream().
bool CFileGZInputStream::fileOpenCorrectly | ( | ) | const |
Returns true if the file was open without errors.
Definition at line 99 of file CFileGZInputStream.cpp.
References m_f.
Referenced by mrpt::io::zip::decompress_gz_file(), is_open(), mrpt::maps::CGasConcentrationGridMap2D::load_Gaussian_Wind_Grid_From_File(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::loadColGridsFromFile(), and mrpt::obs::CRawlog::loadFromRawLogFile().
|
inherited |
Reads from the stream until a '
' character is found ('' characters are ignored).
Definition at line 69 of file CStream.cpp.
|
overridevirtual |
Method for getting the current cursor position in the compressed, where 0 is the first byte and TotalBytesCount-1 the last one.
Implements mrpt::io::CStream.
Definition at line 90 of file CFileGZInputStream.cpp.
References m_f, THE_GZFILE, and THROW_EXCEPTION.
|
overridevirtual |
Method for getting the total number of compressed bytes of in the file (the physical size of the compressed file).
Implements mrpt::io::CStream.
Definition at line 81 of file CFileGZInputStream.cpp.
References m_f, m_file_size, and THROW_EXCEPTION.
Referenced by mrpt::io::zip::decompress_gz_file().
|
inline |
Returns true if the file was open without errors.
Definition at line 57 of file io/CFileGZInputStream.h.
References fileOpenCorrectly().
bool CFileGZInputStream::open | ( | const std::string & | fileName | ) |
Opens the file for read.
fileName | The file to be open in this stream |
Definition at line 36 of file CFileGZInputStream.cpp.
References mrpt::system::getFileSize(), m_f, m_file_size, MRPT_END, MRPT_START, THE_GZFILE, and THROW_EXCEPTION_FMT.
Referenced by CFileGZInputStream(), and mrpt::pbmap::PbMap::loadPbMap().
|
delete |
|
virtualinherited |
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 mrpt::io::CStream::printf_vector().
|
inlineinherited |
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 mrpt::io::CStream::printf().
Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel().
|
overridevirtual |
Introduces a pure virtual method responsible for reading from the stream.
Implements mrpt::io::CStream.
Definition at line 64 of file CFileGZInputStream.cpp.
References m_f, THE_GZFILE, and THROW_EXCEPTION.
Referenced by mrpt::io::zip::decompress_gz_file().
|
inlinevirtualinherited |
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 mrpt::io::CStream::Read().
|
overridevirtual |
This method is not implemented in this class.
Implements mrpt::io::CStream.
Definition at line 108 of file CFileGZInputStream.cpp.
References THROW_EXCEPTION.
|
overridevirtual |
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.
Implements mrpt::io::CStream.
Definition at line 74 of file CFileGZInputStream.cpp.
References MRPT_UNUSED_PARAM, and THROW_EXCEPTION.
|
private |
Definition at line 27 of file io/CFileGZInputStream.h.
Referenced by checkEOF(), close(), fileOpenCorrectly(), getPosition(), getTotalBytesCount(), open(), and Read().
|
private |
Compressed file size.
Definition at line 29 of file io/CFileGZInputStream.h.
Referenced by getTotalBytesCount(), and open().
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020 |