ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QuaZIODevice Class Reference

A class to compress/decompress QIODevice. More...

#include <quaziodevice.h>

Inheritance diagram for QuaZIODevice:
Collaboration diagram for QuaZIODevice:

Public Member Functions

 QuaZIODevice (QIODevice *io, QObject *parent=NULL)
 Constructor. More...
 
 ~QuaZIODevice ()
 Destructor. More...
 
virtual bool flush ()
 Flushes data waiting to be written. More...
 
virtual bool open (QIODevice::OpenMode mode)
 Opens the device. More...
 
virtual void close ()
 Closes this device, but not the underlying one. More...
 
QIODevice * getIoDevice () const
 Returns the underlying device. More...
 
virtual bool isSequential () const
 Returns true. More...
 
virtual bool atEnd () const
 Returns true iff the end of the compressed stream is reached. More...
 
virtual qint64 bytesAvailable () const
 Returns the number of the bytes buffered. More...
 

Protected Member Functions

virtual qint64 readData (char *data, qint64 maxSize)
 Implementation of QIODevice::readData(). More...
 
virtual qint64 writeData (const char *data, qint64 maxSize)
 Implementation of QIODevice::writeData(). More...
 

Detailed Description

A class to compress/decompress QIODevice.

This class can be used to compress any data written to QIODevice or decompress it back. Compressing data sent over a QTcpSocket is a good example.

Definition at line 42 of file quaziodevice.h.

Constructor & Destructor Documentation

◆ QuaZIODevice()

QuaZIODevice::QuaZIODevice ( QIODevice *  io,
QObject *  parent = NULL 
)

Constructor.

Parameters
ioThe QIODevice to read/write.
parentThe parent object, as per QObject logic.

Definition at line 121 of file quaziodevice.cpp.

◆ ~QuaZIODevice()

QuaZIODevice::~QuaZIODevice ( )

Destructor.

Definition at line 126 of file quaziodevice.cpp.

References close(), and isOpen.

Member Function Documentation

◆ atEnd()

bool QuaZIODevice::atEnd ( ) const
virtual

Returns true iff the end of the compressed stream is reached.

Definition at line 318 of file quaziodevice.cpp.

◆ bytesAvailable()

qint64 QuaZIODevice::bytesAvailable ( ) const
virtual

Returns the number of the bytes buffered.

Definition at line 326 of file quaziodevice.cpp.

◆ close()

void QuaZIODevice::close ( )
virtual

Closes this device, but not the underlying one.

The underlying QIODevice is not closed in case you want to write something else to it.

Definition at line 171 of file quaziodevice.cpp.

References flush().

Referenced by ~QuaZIODevice().

◆ flush()

bool QuaZIODevice::flush ( )
virtual

Flushes data waiting to be written.

Unfortunately, as QIODevice doesn't support flush() by itself, the only thing this method does is write the compressed data into the device using Z_SYNC_FLUSH mode. If you need the compressed data to actually be flushed from the buffer of the underlying QIODevice, you need to call its flush() method as well, providing it supports it (like QTcpSocket does). Example:

QuaZIODevice dev(&sock);
dev.open(QIODevice::Write);
dev.write(yourDataGoesHere);
dev.flush();
sock->flush(); // this actually sends data to network
A class to compress/decompress QIODevice.
Definition: quaziodevice.h:42

This may change in the future versions of QuaZIP by implementing an ugly hack: trying to cast the QIODevice using qobject_cast to known flush()-supporting subclasses, and calling flush if the resulting pointer is not zero.

Definition at line 283 of file quaziodevice.cpp.

References error(), and QUAZIO_OUTBUFSIZE.

Referenced by close().

◆ getIoDevice()

QIODevice * QuaZIODevice::getIoDevice ( ) const

Returns the underlying device.

Definition at line 131 of file quaziodevice.cpp.

◆ isSequential()

bool QuaZIODevice::isSequential ( ) const
virtual

Returns true.

Definition at line 316 of file quaziodevice.cpp.

◆ open()

bool QuaZIODevice::open ( QIODevice::OpenMode  mode)
virtual

Opens the device.

Parameters
modeNeither QIODevice::ReadWrite nor QIODevice::Append are not supported.

Definition at line 133 of file quaziodevice.cpp.

References cloudViewer::core::Append().

◆ readData()

qint64 QuaZIODevice::readData ( char *  data,
qint64  maxSize 
)
protectedvirtual

Implementation of QIODevice::readData().

Definition at line 186 of file quaziodevice.cpp.

References QUAZIO_INBUFSIZE.

◆ writeData()

qint64 QuaZIODevice::writeData ( const char *  data,
qint64  maxSize 
)
protectedvirtual

Implementation of QIODevice::writeData().

Definition at line 248 of file quaziodevice.cpp.

References error(), and QUAZIO_OUTBUFSIZE.


The documentation for this class was generated from the following files: