Main MRPT website > C++ reference for MRPT 1.3.2
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-2015, 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  /** Method responsible for reading from the stream.
36  */
37  size_t Read(void *Buffer, size_t Count);
38 
39  /** Method responsible for writing to the stream.
40  * Write attempts to write up to Count bytes to Buffer, and returns the number of bytes actually written.
41  */
42  size_t Write(const void *Buffer, size_t Count);
43 
44  // DECLARE_UNCOPIABLE( CFileGZOutputStream )
45 
46  private:
47  void *m_f;
48 
49  public:
50  /** Constructor: opens an output file with compression level = 1 (minimum, fastest).
51  * \param fileName The file to be open in this stream
52  * \sa open
53  */
54  CFileGZOutputStream(const std::string &fileName);
55 
56  /** Constructor, without opening the file.
57  * \sa open
58  */
60 
61  /** Open a file for write, choosing the compression level
62  * \param fileName The file to be open in this stream
63  * \param compress_level 0:no compression, 1:fastest, 9:best
64  * \return true on success, false on any error.
65  */
66  bool open(const std::string &fileName, int compress_level = 1 );
67 
68  /** Close the file. */
69  void close();
70 
71  /** Destructor
72  */
73  virtual ~CFileGZOutputStream();
74 
75  /** Says if file was open successfully or not.
76  */
77  bool fileOpenCorrectly();
78 
79  /** Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.
80  */
81  uint64_t getPosition();
82 
83  /** This method is not implemented in this class */
84  uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning)
85  {
86  MRPT_UNUSED_PARAM(Offset); MRPT_UNUSED_PARAM(Origin);
87  THROW_EXCEPTION("Seek is not implemented in this class");
88  }
89 
90  /** This method is not implemented in this class */
91  uint64_t getTotalBytesCount()
92  {
93  THROW_EXCEPTION("getTotalBytesCount is not implemented in this class");
94  }
95 
96  }; // End of class def.
97 #endif
98 
99  } // End of namespace
100 } // end of namespace
101 #endif
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:42
#define THROW_EXCEPTION(msg)
class BASE_IMPEXP CStream
Definition: math_frwds.h:26
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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.11 for MRPT 1.3.2 SVN: at Mon May 9 06:50:38 UTC 2016