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  ---------------------------------------------------------------*/
17 namespace 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
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: mrpt_macros.h:110
MRPT_UNUSED_PARAM
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
Definition: mrpt_macros.h:290
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:16
mrpt::utils::CFileGZInputStream::m_f
void * m_f
Definition: CFileGZInputStream.h:34
CStream.h
mrpt::utils::CStream
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
mrpt::utils::CUncopiable
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
Definition: CUncopiable.h:30
mrpt::utils::CFileGZInputStream::m_file_size
uint64_t m_file_size
Compressed file size.
Definition: CFileGZInputStream.h:35
mrpt::utils::CFileGZInputStream
Transparently opens a compressed "gz" file and reads uncompressed data from it.
Definition: CFileGZInputStream.h:28
mrpt::utils::CFileGZInputStream::is_open
bool is_open()
Returns true if the file was open without errors.
Definition: CFileGZInputStream.h:55
mrpt::utils::CStream::TSeekOrigin
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:42
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28



Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 23:11:08 UTC 2019