Main MRPT website > C++ reference for MRPT 1.9.9
io/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-2018, 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 #pragma once
10 
11 #include <mrpt/io/CStream.h>
12 
13 namespace mrpt
14 {
15 namespace io
16 {
17 /** Transparently opens a compressed "gz" file and reads uncompressed data from
18  * 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
21  * available then the class is actually mapped to the standard CFileInputStream
22  *
23  * \sa CFileInputStream
24  * \ingroup mrpt_io_grp
25  */
27 {
28  private:
29  void* m_f;
30  /** Compressed file size */
32 
33  public:
34  /** 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  CFileGZInputStream(const CFileGZInputStream&) = delete;
45 
46  /** Dtor */
47  virtual ~CFileGZInputStream();
48 
49  /** Opens the file for read.
50  * \param fileName The file to be open in this stream
51  * \return false if there's an error opening the file, true otherwise
52  */
53  bool open(const std::string& fileName);
54  /** Closes the file */
55  void close();
56  /** Returns true if the file was open without errors. */
57  bool fileOpenCorrectly() const;
58  /** Returns true if the file was open without errors. */
59  bool is_open() { return fileOpenCorrectly(); }
60  /** Will be true if EOF has been already reached. */
61  bool checkEOF();
62 
63  /** Method for getting the total number of <b>compressed</b> bytes of in the
64  * file (the physical size of the compressed file). */
65  uint64_t getTotalBytesCount() const override;
66  /** Method for getting the current cursor position in the <b>compressed</b>,
67  * where 0 is the first byte and TotalBytesCount-1 the last one. */
68  uint64_t getPosition() const override;
69 
70  /** This method is not implemented in this class */
72  size_t Read(void* Buffer, size_t Count) override;
73  size_t Write(const void* Buffer, size_t Count) override;
74 }; // End of class def.
75 } // End of namespace
76 } // end of namespace
TSeekOrigin
Used in CStream::Seek.
Definition: io/CStream.h:34
uint64_t getPosition() const override
Method for getting the current cursor position in the compressed, where 0 is the first byte and Total...
CFileGZInputStream & operator=(const CFileGZInputStream &)=delete
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:30
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
bool checkEOF()
Will be true if EOF has been already reached.
__int64 int64_t
Definition: rptypes.h:49
uint64_t getTotalBytesCount() const override
Method for getting the total number of compressed bytes of in the file (the physical size of the comp...
GLsizei const GLchar ** string
Definition: glext.h:4101
bool open(const std::string &fileName)
Opens the file for read.
uint64_t Seek(int64_t, CStream::TSeekOrigin=sFromBeginning) override
This method is not implemented in this class.
uint64_t m_file_size
Compressed file size.
unsigned __int64 uint64_t
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void close()
Closes the file.
bool is_open()
Returns true if the file was open without errors.
Transparently opens a compressed "gz" file and reads uncompressed data from it.
CFileGZInputStream()
Constructor without open.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019