MRPT  1.9.9
io/CFileGZOutputStream.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 /** Saves data to a file and transparently compress the data using the given
18  * compression level.
19  * The generated files are in gzip format ("file.gz").
20  * This class requires compiling MRPT with wxWidgets. If wxWidgets is not
21  * available then the class is actually mapped to the standard CFileOutputStream
22  *
23  * \sa CFileOutputStream
24  * \ingroup mrpt_io_grp
25  */
27 {
28  private:
29  struct Impl;
31 
32  public:
33  /** Constructor: opens an output file with compression level = 1 (minimum,
34  * fastest).
35  * \param fileName The file to be open in this stream
36  * \sa open
37  */
38  CFileGZOutputStream(const std::string& fileName);
39 
40  /** Constructor, without opening the file.
41  * \sa open
42  */
44 
47 
48  /** Destructor */
49  ~CFileGZOutputStream() override;
50 
51  /** Open a file for write, choosing the compression level
52  * \param fileName The file to be open in this stream
53  * \param compress_level 0:no compression, 1:fastest, 9:best
54  * \return true on success, false on any error.
55  */
56  bool open(
57  const std::string& fileName, int compress_level = 1,
58  mrpt::optional_ref<std::string> error_msg = std::nullopt);
59  /** Close the file */
60  void close();
61  /** Returns true if the file was open without errors. */
62  bool fileOpenCorrectly() const;
63  /** Returns true if the file was open without errors. */
64  bool is_open() { return fileOpenCorrectly(); }
65  /** Method for getting the current cursor position, where 0 is the first
66  * byte and TotalBytesCount-1 the last one. */
67  uint64_t getPosition() const override;
68 
69  /** This method is not implemented in this class */
71  /** This method is not implemented in this class */
72  uint64_t getTotalBytesCount() const override;
73  size_t Read(void* Buffer, size_t Count) override;
74  size_t Write(const void* Buffer, size_t Count) override;
75 }; // End of class def.
76 static_assert(
77  !std::is_copy_constructible_v<CFileGZOutputStream> &&
78  !std::is_copy_assignable_v<CFileGZOutputStream>,
79  "Copy Check");
80 } // namespace mrpt::io
TSeekOrigin
Used in CStream::Seek.
Definition: io/CStream.h:32
bool open(const std::string &fileName, int compress_level=1, mrpt::optional_ref< std::string > error_msg=std::nullopt)
Open a file for write, choosing the compression level.
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
std::optional< std::reference_wrapper< T > > optional_ref
Shorter name for std::optional<std::reference_wrapper<T>>
Definition: optional_ref.h:20
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:28
GLsizei const GLchar ** string
Definition: glext.h:4116
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
uint64_t getTotalBytesCount() const override
This method is not implemented in this class.
unsigned __int64 uint64_t
Definition: glext.h:3457
bool is_open()
Returns true if the file was open without errors.
CFileGZOutputStream & operator=(const CFileGZOutputStream &)=delete
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
uint64_t Seek(int64_t, CStream::TSeekOrigin=sFromBeginning) override
This method is not implemented in this class.
CFileGZOutputStream()
Constructor, without opening the file.
Saves data to a file and transparently compress the data using the given compression level...
__int64 int64_t
Definition: glext.h:3456
~CFileGZOutputStream() override
Destructor.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 479715d5b Tue Nov 12 07:26:21 2019 +0100 at mar nov 12 07:30:12 CET 2019