MRPT  1.9.9
mrpt::io::CFileGZOutputStream Class Reference

Detailed Description

Saves data to a file and transparently compress the data using the given compression level.

The generated files are in gzip format ("file.gz"). This class requires compiling MRPT with wxWidgets. If wxWidgets is not available then the class is actually mapped to the standard CFileOutputStream

See also
CFileOutputStream

Definition at line 24 of file io/CFileGZOutputStream.h.

#include <mrpt/io/CFileGZOutputStream.h>

Inheritance diagram for mrpt::io::CFileGZOutputStream:
Inheritance graph

Public Types

enum  TSeekOrigin { sFromBeginning = 0, sFromCurrent = 1, sFromEnd = 2 }
 Used in CStream::Seek. More...
 

Public Member Functions

 CFileGZOutputStream (const std::string &fileName)
 Constructor: opens an output file with compression level = 1 (minimum, fastest). More...
 
 CFileGZOutputStream ()
 Constructor, without opening the file. More...
 
 CFileGZOutputStream (const CFileGZOutputStream &)=delete
 
CFileGZOutputStreamoperator= (const CFileGZOutputStream &)=delete
 
virtual ~CFileGZOutputStream ()
 Destructor. More...
 
bool open (const std::string &fileName, int compress_level=1)
 Open a file for write, choosing the compression level. More...
 
void close ()
 Close 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...
 
uint64_t getPosition () const override
 Method for getting the current cursor position, 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...
 
uint64_t getTotalBytesCount () const 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

voidm_f
 

Member Enumeration Documentation

◆ TSeekOrigin

Used in CStream::Seek.

Enumerator
sFromBeginning 
sFromCurrent 
sFromEnd 

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

Constructor & Destructor Documentation

◆ CFileGZOutputStream() [1/3]

CFileGZOutputStream::CFileGZOutputStream ( const std::string fileName)

Constructor: opens an output file with compression level = 1 (minimum, fastest).

Parameters
fileNameThe file to be open in this stream
See also
open

Definition at line 22 of file CFileGZOutputStream.cpp.

References MRPT_END, MRPT_START, open(), and THROW_EXCEPTION_FMT.

◆ CFileGZOutputStream() [2/3]

CFileGZOutputStream::CFileGZOutputStream ( )

Constructor, without opening the file.

See also
open

Definition at line 31 of file CFileGZOutputStream.cpp.

◆ CFileGZOutputStream() [3/3]

mrpt::io::CFileGZOutputStream::CFileGZOutputStream ( const CFileGZOutputStream )
delete

◆ ~CFileGZOutputStream()

CFileGZOutputStream::~CFileGZOutputStream ( )
virtual

Destructor.

Definition at line 45 of file CFileGZOutputStream.cpp.

References close().

Member Function Documentation

◆ close()

void CFileGZOutputStream::close ( )

Close the file.

Definition at line 46 of file CFileGZOutputStream.cpp.

References m_f, and THE_GZFILE.

Referenced by mrpt::pbmap::PbMap::savePbMap(), and ~CFileGZOutputStream().

◆ fileOpenCorrectly()

bool CFileGZOutputStream::fileOpenCorrectly ( ) const

◆ 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 CFileGZOutputStream::getPosition ( ) const
overridevirtual

Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.

Implements mrpt::io::CStream.

Definition at line 69 of file CFileGZOutputStream.cpp.

References m_f, THE_GZFILE, and THROW_EXCEPTION.

◆ getTotalBytesCount()

uint64_t CFileGZOutputStream::getTotalBytesCount ( ) const
overridevirtual

This method is not implemented in this class.

Implements mrpt::io::CStream.

Definition at line 84 of file CFileGZOutputStream.cpp.

References THROW_EXCEPTION.

◆ is_open()

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

Returns true if the file was open without errors.

Definition at line 59 of file io/CFileGZOutputStream.h.

References fileOpenCorrectly().

◆ open()

bool CFileGZOutputStream::open ( const std::string fileName,
int  compress_level = 1 
)

Open a file for write, choosing the compression level.

Parameters
fileNameThe file to be open in this stream
compress_level0:no compression, 1:fastest, 9:best
Returns
true on success, false on any error.

Definition at line 32 of file CFileGZOutputStream.cpp.

References mrpt::format(), m_f, MRPT_END, MRPT_START, and THE_GZFILE.

Referenced by CFileGZOutputStream(), mrpt::io::zip::compress_gz_file(), and mrpt::nav::CAbstractPTGBasedReactive::enableLogFile().

◆ operator=()

CFileGZOutputStream& mrpt::io::CFileGZOutputStream::operator= ( const CFileGZOutputStream )
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 vsnprintf.

Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel(), and mrpt::io::CStream::printf_vector().

◆ 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().

◆ Read()

size_t CFileGZOutputStream::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 55 of file CFileGZOutputStream.cpp.

References THROW_EXCEPTION.

◆ 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().

◆ Seek()

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

This method is not implemented in this class.

Implements mrpt::io::CStream.

Definition at line 79 of file CFileGZOutputStream.cpp.

References THROW_EXCEPTION.

◆ Write()

size_t CFileGZOutputStream::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 60 of file CFileGZOutputStream.cpp.

References m_f, THE_GZFILE, and THROW_EXCEPTION.

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

Member Data Documentation

◆ m_f

void* mrpt::io::CFileGZOutputStream::m_f
private

Definition at line 27 of file io/CFileGZOutputStream.h.

Referenced by close(), fileOpenCorrectly(), getPosition(), open(), and Write().




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