MRPT  1.9.9
io/CFileGZInputStream.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/core/optional_ref.h>
12 #include <mrpt/core/pimpl.h>
13 #include <mrpt/io/CStream.h>
14 
15 namespace mrpt::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  struct Impl;
31  /** Compressed file size */
33 
34  public:
35  /** Constructor without open */
37 
38  /** Constructor and open
39  * \param fileName The file to be open in this stream
40  * \exception std::exception If there's an error opening the file.
41  */
42  CFileGZInputStream(const std::string& fileName);
43 
44  CFileGZInputStream(const CFileGZInputStream&) = delete;
46 
47  /** Dtor */
48  ~CFileGZInputStream() override;
49 
50  /** Opens the file for read.
51  * \param fileName The file to be open in this stream
52  * \return false if there's an error opening the file, true otherwise
53  */
54  bool open(
55  const std::string& fileName,
56  mrpt::optional_ref<std::string> error_msg = std::nullopt);
57  /** Closes the file */
58  void close();
59  /** Returns true if the file was open without errors. */
60  bool fileOpenCorrectly() const;
61  /** Returns true if the file was open without errors. */
62  bool is_open() { return fileOpenCorrectly(); }
63  /** Will be true if EOF has been already reached. */
64  bool checkEOF();
65 
66  /** Method for getting the total number of <b>compressed</b> bytes of in the
67  * file (the physical size of the compressed file). */
68  uint64_t getTotalBytesCount() const override;
69  /** Method for getting the current cursor position in the <b>compressed</b>,
70  * where 0 is the first byte and TotalBytesCount-1 the last one. */
71  uint64_t getPosition() const override;
72 
73  /** This method is not implemented in this class */
75  size_t Read(void* Buffer, size_t Count) override;
76  size_t Write(const void* Buffer, size_t Count) override;
77 }; // End of class def.
78 } // namespace mrpt::io
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...
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
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.
std::optional< std::reference_wrapper< T > > optional_ref
Shorter name for std::optional<std::reference_wrapper<T>>
Definition: optional_ref.h:20
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 open(const std::string &fileName, mrpt::optional_ref< std::string > error_msg=std::nullopt)
Opens the file for read.
bool checkEOF()
Will be true if EOF has been already reached.
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:4116
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: glext.h:3457
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.
__int64 int64_t
Definition: glext.h:3456



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 45d659fbb Tue Dec 10 18:21:14 2019 +0100 at mar dic 10 18:30:09 CET 2019