Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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 namespace mrpt
15 {
16  namespace utils
17  {
18  /** Transparently opens a compressed "gz" file and reads uncompressed data from 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 available then the class is actually mapped to the standard CFileInputStream
21  *
22  * \sa CFileInputStream
23  * \ingroup mrpt_base_grp
24  */
26  {
27  protected:
28  size_t Read(void *Buffer, size_t Count) MRPT_OVERRIDE;
29  size_t Write(const void *Buffer, size_t Count) MRPT_OVERRIDE;
30  private:
31  void *m_f;
32  uint64_t m_file_size; //!< Compressed file size
33 
34  public:
35  CFileGZInputStream(); //!< 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  virtual ~CFileGZInputStream(); //!< Dtor
44 
45  /** Opens the file for read.
46  * \param fileName The file to be open in this stream
47  * \return false if there's an error opening the file, true otherwise
48  */
49  bool open(const std::string &fileName );
50  void close(); //!< Closes the file
51  bool fileOpenCorrectly(); //!< Returns true if the file was open without errors.
52  bool is_open() { return fileOpenCorrectly(); } //!< Returns true if the file was open without errors.
53  bool checkEOF(); //!< Will be true if EOF has been already reached.
54 
55  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).
56  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.
57 
58  /** This method is not implemented in this class */
59  uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning) MRPT_OVERRIDE
60  {
61  MRPT_UNUSED_PARAM(Offset); MRPT_UNUSED_PARAM(Origin);
62  THROW_EXCEPTION("Seek is not implemented in this class");
63  }
64 
65  }; // End of class def.
66 
67  } // End of namespace
68 } // end of namespace
69 #endif
uint64_t m_file_size
Compressed file size.
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:42
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define THROW_EXCEPTION(msg)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
__int64 int64_t
Definition: rptypes.h:51
Transparently opens a compressed "gz" file and reads uncompressed data from it.
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
Definition: CUncopiable.h:30
bool is_open()
Returns true if the file was open without errors.
GLsizei const GLchar ** string
Definition: glext.h:3919
unsigned __int64 uint64_t
Definition: rptypes.h:52
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019