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



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020