MRPT  2.0.1
List of all members | Classes | Public Types | Public Member Functions | Private Attributes
mrpt::io::CFileGZInputStream Class Reference

Detailed Description

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

See also
CFileInputStream

Definition at line 26 of file io/CFileGZInputStream.h.

#include <mrpt/io/CFileGZInputStream.h>

Inheritance diagram for mrpt::io::CFileGZInputStream:

Classes

struct  Impl
 

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
 
CFileGZInputStreamoperator= (const CFileGZInputStream &)=delete
 
 ~CFileGZInputStream () override
 Dtor. More...
 
bool open (const std::string &fileName, mrpt::optional_ref< std::string > error_msg=std::nullopt)
 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

mrpt::pimpl< Implm_f
 
uint64_t m_file_size {0}
 Compressed file size. More...
 

Member Enumeration Documentation

◆ TSeekOrigin

Used in CStream::Seek.

Enumerator
sFromBeginning 
sFromCurrent 
sFromEnd 

Definition at line 32 of file io/CStream.h.

Constructor & Destructor Documentation

◆ CFileGZInputStream() [1/3]

CFileGZInputStream::CFileGZInputStream ( )

Constructor without open.

Definition at line 33 of file CFileGZInputStream.cpp.

◆ CFileGZInputStream() [2/3]

CFileGZInputStream::CFileGZInputStream ( const std::string &  fileName)

Constructor and open.

Parameters
fileNameThe file to be open in this stream
Exceptions
std::exceptionIf there's an error opening the file.

Definition at line 38 of file CFileGZInputStream.cpp.

References MRPT_END, MRPT_START, and open().

Here is the call graph for this function:

◆ CFileGZInputStream() [3/3]

mrpt::io::CFileGZInputStream::CFileGZInputStream ( const CFileGZInputStream )
delete

◆ ~CFileGZInputStream()

CFileGZInputStream::~CFileGZInputStream ( )
override

Dtor.

Definition at line 81 of file CFileGZInputStream.cpp.

References close().

Here is the call graph for this function:

Member Function Documentation

◆ checkEOF()

bool CFileGZInputStream::checkEOF ( )

Will be true if EOF has been already reached.

Definition at line 117 of file CFileGZInputStream.cpp.

References m_f.

◆ close()

void CFileGZInputStream::close ( )

Closes the file.

Definition at line 72 of file CFileGZInputStream.cpp.

References m_f.

Referenced by ~CFileGZInputStream().

Here is the caller graph for this function:

◆ fileOpenCorrectly()

bool CFileGZInputStream::fileOpenCorrectly ( ) const

Returns true if the file was open without errors.

Definition at line 116 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(), and mrpt::nav::CPTG_DiffDrive_CollisionGridBased::loadColGridsFromFile().

Here is the caller graph for this function:

◆ getline()

bool CStream::getline ( std::string &  out_str)
inherited

Reads from the stream until a '
' character is found ('' characters are ignored).

Returns
false on EOF or any other read error.

Definition at line 69 of file CStream.cpp.

◆ getPosition()

uint64_t CFileGZInputStream::getPosition ( ) const
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 107 of file CFileGZInputStream.cpp.

References m_f, and THROW_EXCEPTION.

◆ getTotalBytesCount()

uint64_t CFileGZInputStream::getTotalBytesCount ( ) const
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 98 of file CFileGZInputStream.cpp.

References m_f, m_file_size, and THROW_EXCEPTION.

Referenced by mrpt::io::zip::decompress_gz_file().

Here is the caller graph for this function:

◆ is_open()

bool mrpt::io::CFileGZInputStream::is_open ( )
inline

Returns true if the file was open without errors.

Definition at line 62 of file io/CFileGZInputStream.h.

References fileOpenCorrectly().

Here is the call graph for this function:

◆ open()

bool CFileGZInputStream::open ( const std::string &  fileName,
mrpt::optional_ref< std::string >  error_msg = std::nullopt 
)

Opens the file for read.

Parameters
fileNameThe file to be open in this stream
Returns
false if there's an error opening the file, true otherwise

Definition at line 46 of file CFileGZInputStream.cpp.

References mrpt::format(), mrpt::system::getFileSize(), m_f, m_file_size, MRPT_END, and MRPT_START.

Referenced by CFileGZInputStream(), mrpt::apps::DataSourceRawlog::impl_get_next_observations(), mrpt::maps::CPointsMapXYZI::loadFromKittiVelodyneFile(), mrpt::obs::CRawlog::loadFromRawLogFile(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

CFileGZInputStream& mrpt::io::CFileGZInputStream::operator= ( const CFileGZInputStream )
delete

◆ printf()

int CStream::printf ( const char *  fmt,
  ... 
)
virtualinherited

Writes a string to the stream in a textual form.

See also
CStdOutStream

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(), mrpt::io::CStream::printf_vector(), mrpt::apps::CGridMapAlignerApp::run(), mrpt::apps::RBPF_SLAM_App_Base::run(), and mrpt::apps::ICP_SLAM_App_Base::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printf_vector()

template<typename CONTAINER_TYPE >
virtual int void mrpt::io::CStream::printf_vector ( const char *  fmt,
const CONTAINER_TYPE &  V,
char  separator = ',' 
)
inlineinherited

Prints a vector in the format [A,B,C,...] using CStream::printf, and the fmt string for each vector element T.

Template Parameters
CONTAINER_TYPEcan 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read()

size_t CFileGZInputStream::Read ( void *  Buffer,
size_t  Count 
)
overridevirtual

Introduces a pure virtual method responsible for reading from the stream.

Implements mrpt::io::CStream.

Definition at line 82 of file CFileGZInputStream.cpp.

References m_f, and THROW_EXCEPTION.

Referenced by mrpt::io::zip::decompress_gz_file(), and TEST().

Here is the caller graph for this function:

◆ ReadBufferImmediate()

virtual size_t mrpt::io::CStream::ReadBufferImmediate ( void *  Buffer,
size_t  Count 
)
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.

Exceptions
std::exceptionOn 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().

Here is the call graph for this function:

◆ Seek()

uint64_t CFileGZInputStream::Seek ( int64_t  ,
CStream::TSeekOrigin  = sFromBeginning 
)
overridevirtual

This method is not implemented in this class.

Implements mrpt::io::CStream.

Definition at line 125 of file CFileGZInputStream.cpp.

References THROW_EXCEPTION.

◆ Write()

size_t CFileGZInputStream::Write ( const void *  Buffer,
size_t  Count 
)
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 92 of file CFileGZInputStream.cpp.

References THROW_EXCEPTION.

Member Data Documentation

◆ m_f

mrpt::pimpl<Impl> mrpt::io::CFileGZInputStream::m_f
private

◆ m_file_size

uint64_t mrpt::io::CFileGZInputStream::m_file_size {0}
private

Compressed file size.

Definition at line 32 of file io/CFileGZInputStream.h.

Referenced by getTotalBytesCount(), and open().




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