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::io
14 {
15 /** Transparently opens a compressed "gz" file and reads uncompressed data from
16  * it.
17  * If the file is not a .gz file, it silently reads data from the file.
18  * This class requires compiling MRPT with wxWidgets. If wxWidgets is not
19  * available then the class is actually mapped to the standard CFileInputStream
20  *
21  * \sa CFileInputStream
22  * \ingroup mrpt_io_grp
23  */
25 {
26  private:
27  void* m_f;
28  /** Compressed file size */
30 
31  public:
32  /** Constructor without open */
34 
35  /** Constructor and open
36  * \param fileName The file to be open in this stream
37  * \exception std::exception If there's an error opening the file.
38  */
39  CFileGZInputStream(const std::string& fileName);
40 
41  CFileGZInputStream(const CFileGZInputStream&) = delete;
43 
44  /** Dtor */
45  virtual ~CFileGZInputStream();
46 
47  /** Opens the file for read.
48  * \param fileName The file to be open in this stream
49  * \return false if there's an error opening the file, true otherwise
50  */
51  bool open(const std::string& fileName);
52  /** Closes the file */
53  void close();
54  /** Returns true if the file was open without errors. */
55  bool fileOpenCorrectly() const;
56  /** Returns true if the file was open without errors. */
57  bool is_open() { return fileOpenCorrectly(); }
58  /** Will be true if EOF has been already reached. */
59  bool checkEOF();
60 
61  /** Method for getting the total number of <b>compressed</b> bytes of in the
62  * file (the physical size of the compressed file). */
63  uint64_t getTotalBytesCount() const override;
64  /** Method for getting the current cursor position in the <b>compressed</b>,
65  * where 0 is the first byte and TotalBytesCount-1 the last one. */
66  uint64_t getPosition() const override;
67 
68  /** This method is not implemented in this class */
70  size_t Read(void* Buffer, size_t Count) override;
71  size_t Write(const void* Buffer, size_t Count) override;
72 }; // End of class def.
73 }
74 
TSeekOrigin
Used in CStream::Seek.
Definition: io/CStream.h:32
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:28
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
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020