Main MRPT website > C++ reference for MRPT 1.9.9
CFileGZOutputStream.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 CFileGZOutputStream_H
10 #define CFileGZOutputStream_H
11 
12 #include <mrpt/utils/CStream.h>
13 
14 namespace mrpt
15 {
16 namespace utils
17 {
18 /** Saves data to a file and transparently compress the data using the given
19  * compression level.
20  * The generated files are in gzip format ("file.gz").
21  * This class requires compiling MRPT with wxWidgets. If wxWidgets is not
22  * available then the class is actually mapped to the standard CFileOutputStream
23  *
24  * \sa CFileOutputStream
25  * \ingroup mrpt_base_grp
26  */
27 #if !MRPT_HAS_GZ_STREAMS
28 // We don't have wxwidgets:
29 #define CFileGZOutputStream CFileOutputStream
30 #else
31 class CFileGZOutputStream : public CStream
32 {
33  protected:
34  size_t Read(void* Buffer, size_t Count) override;
35  size_t Write(const void* Buffer, size_t Count) override;
36  // DECLARE_UNCOPIABLE( CFileGZOutputStream )
37  private:
38  void* m_f;
39 
40  public:
41  /** Constructor: opens an output file with compression level = 1 (minimum,
42  * fastest).
43  * \param fileName The file to be open in this stream
44  * \sa open
45  */
46  CFileGZOutputStream(const std::string& fileName);
47 
48  /** Constructor, without opening the file.
49  * \sa open
50  */
52 
54  CFileGZOutputStream& operator=(const CFileGZOutputStream&) = delete;
55 
56  /** Destructor */
57  virtual ~CFileGZOutputStream();
58 
59  /** Open a file for write, choosing the compression level
60  * \param fileName The file to be open in this stream
61  * \param compress_level 0:no compression, 1:fastest, 9:best
62  * \return true on success, false on any error.
63  */
64  bool open(const std::string& fileName, int compress_level = 1);
65  /** Close the file */
66  void close();
67  /** Returns true if the file was open without errors. */
68  bool fileOpenCorrectly();
69  /** Returns true if the file was open without errors. */
70  bool is_open() { return fileOpenCorrectly(); }
71  /** Method for getting the current cursor position, where 0 is the first
72  * byte and TotalBytesCount-1 the last one. */
73  uint64_t getPosition() override;
74 
75  /** This method is not implemented in this class */
76  uint64_t Seek(
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  /** This method is not implemented in this class */
85  uint64_t getTotalBytesCount() override
86  {
87  THROW_EXCEPTION("getTotalBytesCount is not implemented in this class");
88  }
89 }; // End of class def.
90 static_assert(
93  "Copy Check");
94 #endif
95 
96 } // End of namespace
97 } // end of namespace
98 #endif
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:45
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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.
#define CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level...
GLsizei const GLfloat * value
Definition: glext.h:4117



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