Main MRPT website > C++ reference for MRPT 1.9.9
io/CFileGZInputStream.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/io/CStream.h>
12 
13 namespace mrpt
14 {
15 namespace io
16 {
17 /** Transparently opens a compressed "gz" file and reads uncompressed data from
18  * it.
19  * If the file is not a .gz file, it silently reads data from the file.
20  * This class requires compiling MRPT with wxWidgets. If wxWidgets is not
21  * available then the class is actually mapped to the standard CFileInputStream
22  *
23  * \sa CFileInputStream
24  * \ingroup mrpt_io_grp
25  */
27 {
28  private:
29  void* m_f;
30  /** Compressed file size */
32 
33  public:
34  /** Constructor without open */
36 
37  /** Constructor and open
38  * \param fileName The file to be open in this stream
39  * \exception std::exception If there's an error opening the file.
40  */
41  CFileGZInputStream(const std::string& fileName);
42 
43  CFileGZInputStream(const CFileGZInputStream&) = delete;
45 
46  /** Dtor */
47  virtual ~CFileGZInputStream();
48 
49  /** Opens the file for read.
50  * \param fileName The file to be open in this stream
51  * \return false if there's an error opening the file, true otherwise
52  */
53  bool open(const std::string& fileName);
54  /** Closes the file */
55  void close();
56  /** Returns true if the file was open without errors. */
57  bool fileOpenCorrectly() const;
58  /** Returns true if the file was open without errors. */
59  bool is_open() { return fileOpenCorrectly(); }
60  /** Will be true if EOF has been already reached. */
61  bool checkEOF();
62 
63  /** Method for getting the total number of <b>compressed</b> bytes of in the
64  * file (the physical size of the compressed file). */
65  uint64_t getTotalBytesCount() const override;
66  /** Method for getting the current cursor position in the <b>compressed</b>,
67  * where 0 is the first byte and TotalBytesCount-1 the last one. */
68  uint64_t getPosition() const override;
69 
70  /** This method is not implemented in this class */
72  size_t Read(void* Buffer, size_t Count) override;
73  size_t Write(const void* Buffer, size_t Count) override;
74 }; // End of class def.
75 } // End of namespace
76 } // end of namespace
mrpt::io::CStream::TSeekOrigin
TSeekOrigin
Used in CStream::Seek.
Definition: io/CStream.h:34
mrpt::io::CFileGZInputStream::operator=
CFileGZInputStream & operator=(const CFileGZInputStream &)=delete
mrpt::io::CFileGZInputStream::CFileGZInputStream
CFileGZInputStream()
Constructor without open.
Definition: CFileGZInputStream.cpp:35
mrpt::io::CFileGZInputStream::m_f
void * m_f
Definition: io/CFileGZInputStream.h:29
mrpt::io::CFileGZInputStream::Write
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
Definition: CFileGZInputStream.cpp:74
int64_t
__int64 int64_t
Definition: rptypes.h:49
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::io::CFileGZInputStream::getTotalBytesCount
uint64_t getTotalBytesCount() const override
Method for getting the total number of compressed bytes of in the file (the physical size of the comp...
Definition: CFileGZInputStream.cpp:81
mrpt::io::CFileGZInputStream::~CFileGZInputStream
virtual ~CFileGZInputStream()
Dtor.
Definition: CFileGZInputStream.cpp:63
mrpt::io::CFileGZInputStream::Read
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
Definition: CFileGZInputStream.cpp:64
mrpt::io::CFileGZInputStream::Seek
uint64_t Seek(int64_t, CStream::TSeekOrigin=sFromBeginning) override
This method is not implemented in this class.
Definition: CFileGZInputStream.cpp:108
mrpt::io::CFileGZInputStream::open
bool open(const std::string &fileName)
Opens the file for read.
Definition: CFileGZInputStream.cpp:36
mrpt::io::CFileGZInputStream
Transparently opens a compressed "gz" file and reads uncompressed data from it.
Definition: io/CFileGZInputStream.h:26
mrpt::io::CFileGZInputStream::close
void close()
Closes the file.
Definition: CFileGZInputStream.cpp:54
mrpt::io::CStream::sFromBeginning
@ sFromBeginning
Definition: io/CStream.h:36
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
CStream.h
mrpt::io::CFileGZInputStream::is_open
bool is_open()
Returns true if the file was open without errors.
Definition: io/CFileGZInputStream.h:59
mrpt::io::CFileGZInputStream::m_file_size
uint64_t m_file_size
Compressed file size.
Definition: io/CFileGZInputStream.h:31
mrpt::io::CFileGZInputStream::getPosition
uint64_t getPosition() const override
Method for getting the current cursor position in the compressed, where 0 is the first byte and Total...
Definition: CFileGZInputStream.cpp:90
mrpt::io::CFileGZInputStream::checkEOF
bool checkEOF()
Will be true if EOF has been already reached.
Definition: CFileGZInputStream.cpp:100
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::io::CFileGZInputStream::fileOpenCorrectly
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
Definition: CFileGZInputStream.cpp:99
mrpt::io::CStream
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:30



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST