Main MRPT website > C++ reference for MRPT 1.9.9
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
19  * it.
20  * If the file is not a .gz file, it silently reads data from the file.
21  * This class requires compiling MRPT with wxWidgets. If wxWidgets is not
22  * available then the class is actually mapped to the standard CFileInputStream
23  *
24  * \sa CFileInputStream
25  * \ingroup mrpt_base_grp
26  */
28 {
29  protected:
30  size_t Read(void* Buffer, size_t Count) override;
31  size_t Write(const void* Buffer, size_t Count) override;
32 
33  private:
34  void* m_f;
35  /** Compressed file size */
37 
38  public:
39  /** Constructor without open */
41 
42  /** Constructor and open
43  * \param fileName The file to be open in this stream
44  * \exception std::exception If there's an error opening the file.
45  */
46  CFileGZInputStream(const std::string& fileName);
47 
48  CFileGZInputStream(const CFileGZInputStream&) = delete;
50 
51  /** Dtor */
52  virtual ~CFileGZInputStream();
53 
54  /** Opens the file for read.
55  * \param fileName The file to be open in this stream
56  * \return false if there's an error opening the file, true otherwise
57  */
58  bool open(const std::string& fileName);
59  /** Closes the file */
60  void close();
61  /** Returns true if the file was open without errors. */
62  bool fileOpenCorrectly();
63  /** Returns true if the file was open without errors. */
64  bool is_open() { return fileOpenCorrectly(); }
65  /** Will be true if EOF has been already reached. */
66  bool checkEOF();
67 
68  /** Method for getting the total number of <b>compressed</b> bytes of in the
69  * file (the physical size of the compressed file). */
70  uint64_t getTotalBytesCount() override;
71  /** Method for getting the current cursor position in the <b>compressed</b>,
72  * where 0 is the first byte and TotalBytesCount-1 the last one. */
73  uint64_t getPosition() override;
74 
75  /** This method is not implemented in this class */
77  uint64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning) override
78  {
79  MRPT_UNUSED_PARAM(Offset);
80  MRPT_UNUSED_PARAM(Origin);
81  THROW_EXCEPTION("Seek is not implemented in this class");
82  }
83 
84 }; // End of class def.
85 
86 static_assert(
89  "Copy Check");
90 } // End of namespace
91 } // end of namespace
92 #endif
uint64_t m_file_size
Compressed file size.
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
This method is not implemented in this class.
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:45
bool open(const std::string &fileName)
Opens the file for read.
#define THROW_EXCEPTION(msg)
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
uint64_t getTotalBytesCount() override
Method for getting the total number of compressed bytes of in the file (the physical size of the comp...
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
#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.
CFileGZInputStream & operator=(const CFileGZInputStream &)=delete
bool is_open()
Returns true if the file was open without errors.
GLsizei const GLchar ** string
Definition: glext.h:4101
unsigned __int64 uint64_t
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool fileOpenCorrectly()
Returns true if the file was open without errors.
bool checkEOF()
Will be true if EOF has been already reached.
CFileGZInputStream()
Constructor without open.
GLsizei const GLfloat * value
Definition: glext.h:4117
uint64_t getPosition() override
Method for getting the current cursor position in the compressed, where 0 is the first byte and Total...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019