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



Page generated by Doxygen 1.8.17 for MRPT 1.4.0 SVN: at Sat Jan 18 22:37:07 UTC 2020