Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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#ifndef CFileGZInputStream_H
10#define CFileGZInputStream_H
11
12#include <mrpt/utils/CStream.h>
13
14/*---------------------------------------------------------------
15 Class
16 ---------------------------------------------------------------*/
17namespace mrpt
18{
19 namespace utils
20 {
21 /** Transparently opens a compressed "gz" file and reads uncompressed data from it.
22 * If the file is not a .gz file, it silently reads data from the file.
23 * This class requires compiling MRPT with wxWidgets. If wxWidgets is not available then the class is actually mapped to the standard CFileInputStream
24 *
25 * \sa CFileInputStream
26 * \ingroup mrpt_base_grp
27 */
29 {
30 protected:
31 size_t Read(void *Buffer, size_t Count) MRPT_OVERRIDE;
32 size_t Write(const void *Buffer, size_t Count) MRPT_OVERRIDE;
33 private:
34 void *m_f;
35 uint64_t m_file_size; //!< Compressed file size
36
37 public:
38 CFileGZInputStream(); //!< Constructor without open
39
40 /** Constructor and open
41 * \param fileName The file to be open in this stream
42 * \exception std::exception If there's an error opening the file.
43 */
44 CFileGZInputStream(const std::string &fileName );
45
46 virtual ~CFileGZInputStream(); //!< Dtor
47
48 /** Opens the file for read.
49 * \param fileName The file to be open in this stream
50 * \return false if there's an error opening the file, true otherwise
51 */
52 bool open(const std::string &fileName );
53 void close(); //!< Closes the file
54 bool fileOpenCorrectly(); //!< Returns true if the file was open without errors.
55 bool is_open() { return fileOpenCorrectly(); } //!< Returns true if the file was open without errors.
56 bool checkEOF(); //!< Will be true if EOF has been already reached.
57
58 uint64_t getTotalBytesCount() MRPT_OVERRIDE; //!< Method for getting the total number of <b>compressed</b> bytes of in the file (the physical size of the compressed file).
59 uint64_t getPosition() MRPT_OVERRIDE; //!< Method for getting the current cursor position in the <b>compressed</b>, where 0 is the first byte and TotalBytesCount-1 the last one.
60
61 /** This method is not implemented in this class */
62 uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning) MRPT_OVERRIDE
63 {
64 MRPT_UNUSED_PARAM(Offset); MRPT_UNUSED_PARAM(Origin);
65 THROW_EXCEPTION("Seek is not implemented in this class");
66 }
67
68 }; // End of class def.
69
70 } // End of namespace
71} // end of namespace
72#endif
Transparently opens a compressed "gz" file and reads uncompressed data from it.
bool checkEOF()
Will be true if EOF has been already reached.
void close()
Closes the file.
bool is_open()
Returns true if the file was open without errors.
size_t Read(void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a pure virtual method responsible for reading from the stream.
CFileGZInputStream()
Constructor without open.
CFileGZInputStream(const std::string &fileName)
Constructor and open.
bool fileOpenCorrectly()
Returns true if the file was open without errors.
uint64_t getTotalBytesCount() MRPT_OVERRIDE
Method for getting the total number of compressed bytes of in the file (the physical size of the comp...
size_t Write(const void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a pure virtual method responsible for writing to the stream.
bool open(const std::string &fileName)
Opens the file for read.
uint64_t m_file_size
Compressed file size.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition CStream.h:39
TSeekOrigin
Used in CStream::Seek.
Definition CStream.h:43
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
Definition CUncopiable.h:31
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition mrpt_macros.h:28
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.8 for MRPT 1.4.0 SVN: at Thu Dec 14 16:54:58 UTC 2023