Main MRPT website > C++ reference for MRPT 1.3.2
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-2015, 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  /** Method responsible for reading from the stream.
32  */
33  size_t Read(void *Buffer, size_t Count);
34 
35  /** Method responsible for writing to the stream.
36  * Write attempts to write up to Count bytes to Buffer, and returns the number of bytes actually written.
37  */
38  size_t Write(const void *Buffer, size_t Count);
39 
40  // DECLARE_UNCOPIABLE( CFileGZInputStream )
41 
42  private:
43  void *m_f;
44  uint64_t m_file_size; //!< Compressed file size
45 
46  public:
47  /** Constructor without open
48  */
50 
51  /** Constructor and open
52  * \param fileName The file to be open in this stream
53  * \exception std::exception If there's an error opening the file.
54  */
55  CFileGZInputStream(const std::string &fileName );
56 
57  /** Destructor
58  */
59  virtual ~CFileGZInputStream();
60 
61  /** Opens the file for read.
62  * \param fileName The file to be open in this stream
63  * \return false if there's an error opening the file, true otherwise
64  */
65  bool open(const std::string &fileName );
66 
67  /** Closes the file */
68  void close();
69 
70  /** Says if file was open successfully or not.
71  */
72  bool fileOpenCorrectly();
73 
74  /** Will be true if EOF has been already reached.
75  */
76  bool checkEOF();
77 
78  /** Method for getting the total number of <b>compressed</b> bytes of in the file (the physical size of the compressed file).
79  */
80  uint64_t getTotalBytesCount();
81 
82  /** Method for getting the current cursor position in the <b>compressed</b>, where 0 is the first byte and TotalBytesCount-1 the last one.
83  */
84  uint64_t getPosition();
85 
86  /** This method is not implemented in this class */
87  uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning)
88  {
89  MRPT_UNUSED_PARAM(Offset); MRPT_UNUSED_PARAM(Origin);
90  THROW_EXCEPTION("Seek is not implemented in this class");
91  }
92 
93  }; // End of class def.
94 
95  } // End of namespace
96 } // end of namespace
97 #endif
uint64_t m_file_size
Compressed file size.
#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.
Transparently opens a compressed "gz" file and reads uncompressed data from it.
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:42
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
Definition: CUncopiable.h:30
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning)
This method is not implemented in this class.



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.2 SVN:Unversioned directory at Thu Dec 10 00:07:55 UTC 2015