Class CFileGZOutputStream
Defined in File CFileGZOutputStream.h
Inheritance Relationships
Base Type
public mrpt::io::CStream(Class CStream)
Class Documentation
-
class CFileGZOutputStream : public mrpt::io::CStream
Saves data to a file and transparently compress the data using the given compression level. The generated files are in gzip format (“file.gz”).
See also
Public Functions
-
CFileGZOutputStream(const std::string &fileName, const OpenMode mode = OpenMode::TRUNCATE, int compressionLevel = 1)
Constructor: opens an output file with the given compression level (Default= 1, the minimum, fastest).
- Parameters:
fileName – The file to be open in this stream
append – If set to true, the file will be opened for writing and the current cursor position set at the end of the file. Otherwise, previous contents will be lost.
- Throws:
std::exception – if the file cannot be opened.
-
CFileGZOutputStream(const CFileGZOutputStream&) = delete
-
CFileGZOutputStream &operator=(const CFileGZOutputStream&) = delete
-
~CFileGZOutputStream() override
Destructor
-
virtual std::string getStreamDescription() const override
Returns a human-friendly description of the stream, e.g. a filename.
-
bool open(const std::string &fileName, int compress_level = 1, mrpt::optional_ref<std::string> error_msg = std::nullopt, const OpenMode mode = OpenMode::TRUNCATE)
Open a file for write, choosing the compression level
- Parameters:
fileName – The file to be open in this stream
compress_level – 0:no compression, 1:fastest, 9:best
- Returns:
true on success, false on any error.
-
void close()
Close the file
-
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
-
inline bool is_open()
Returns true if the file was open without errors.
-
virtual uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the last one.
-
std::string filePathAtUse() const
Returns the path of the filename passed to open(), or empty if none.
-
virtual uint64_t Seek(int64_t, CStream::TSeekOrigin = sFromBeginning) override
This method is not implemented in this class
-
virtual uint64_t getTotalBytesCount() const override
This method is not implemented in this class
-
virtual size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
-
virtual size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream. Write attempts to write up to Count bytes to Buffer, and returns the number of bytes actually written.
-
CFileGZOutputStream(const std::string &fileName, const OpenMode mode = OpenMode::TRUNCATE, int compressionLevel = 1)