FX::QGZipDevice Class Reference
[File type i/o devices]

#include <QGZipDevice.h>

Inheritance diagram for FX::QGZipDevice:

FX::QIODevice List of all members.

Detailed Description

Provides a filter i/o device which transparently translates .gz files.

This is a useful little class which shows the power of the TnFOX i/o class structure. Quite simply, it takes a QIODevice which accesses the .gz file and provides the decompressed version to anything using it. You can use it for reading or writing.

You can especially combine this with QTrans translation files to markedly reduce their size and loading time. Simply attach the i/o device accessing the translation file to an instance of this class using setGZData(). Then read from this instance instead.

Implementation notes:

Since the process of inflation and deflation is slow, the class internally decompresses to a QBuffer on open() and all work is done to and from this buffer. Only on close() or flush() is the data in the buffer gzipped back to the gzdata source.

The source if not already open is opened on open() - if being reopened it does not reset the file pointer so ensure it's at the right place. After open() it leaves the file pointer pointing after the .gz data.

On close() or flush(), the file pointer is first set to zero and after writing a truncate() is issued to the source to remove any extraneous data. If opened as read only or write only, the device behaves correctly and doesn't issue anything incorrect (or at least it shouldn't!). QGZipDevice never closes the source when you close() it.

Note:
You need the zlib library available for this to work. If it's missing an exception is generated if you try to use it.
This class uses the zlib library and hacked together parts of its sample code (C) 1995-1998 Jean-loup Gailly and Mark Adler

Definition at line 70 of file QGZipDevice.h.

Public Types

typedef FXfval Offset
 Default
 Unix
 MacOS
 MSDOS
 NoTranslation
 UTF8
 UTF16
 UTF16LE
 UTF32
 UTF32LE
enum  CRLFType { Default, Unix, MacOS, MSDOS }
enum  UnicodeType {
  NoTranslation, UTF8, UTF16, UTF16LE,
  UTF32, UTF32LE
}

Public Member Functions

 QGZipDevice (QIODevice *gzdata=0)
 ~QGZipDevice ()
QIODeviceGZData () const
void setGZData (QIODevice *gzdata)
virtual bool open (FXuint mode)
virtual void close ()
virtual void flush ()
virtual FXfval size () const
virtual void truncate (FXfval size)
virtual FXfval at () const
virtual bool at (FXfval newpos)
virtual bool atEnd () const
virtual FXuval readBlock (char *data, FXuval maxlen)
virtual FXuval writeBlock (const char *data, FXuval maxlen)
virtual FXuval readBlockFrom (char *data, FXuval maxlen, FXfval pos)
virtual FXuval writeBlockTo (FXfval pos, const char *data, FXuval maxlen)
virtual int getch ()
virtual int putch (int c)
virtual int ungetch (int c)
FXuint flags () const
FXuint mode () const
FXuint state () const
CRLFType crlfFormat () const
void setCRLFFormat (CRLFType type)
UnicodeType unicodeTranslation () const
void setUnicodeTranslation (UnicodeType type)
bool isBuffered () const
bool isRaw () const
bool isTranslated () const
bool isUTF16Translated () const
bool isUTF32Translated () const
bool isReadable () const
bool isWriteable () const
bool isWritable () const
bool isReadWrite () const
bool isClosed () const
bool isInactive () const
bool isOpen () const
virtual bool isSynchronous () const
virtual const FXACLpermissions () const
virtual void setPermissions (const FXACL &)
FXuval readBlock (FXuchar *data, FXuval maxlen)
FXuval writeBlock (const FXuchar *data, FXuval maxlen)
virtual FXuval readLine (char *data, FXuval maxlen)
FXuval readBlockFrom (FXuchar *data, FXuval maxlen, FXfval pos)
FXuval writeBlockTo (FXfval pos, const FXuchar *data, FXuval maxlen)
FXfval shredData (FXfval offset, FXfval len=(FXfval)-1)

Static Public Member Functions

static UnicodeType determineUnicodeType (FXuchar *data, FXuval len) throw ()
static FXuval applyCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, CRLFType crlftype=Default, UnicodeType utftype=NoTranslation)
static FXuval removeCRLF (FXuchar *FXRESTRICT output, const FXuchar *FXRESTRICT input, FXuval outputlen, FXuval &inputlen, UnicodeType utftype=NoTranslation)

Protected Member Functions

void setFlags (int f)
void setMode (int m)
void setState (int s)

Protected Attributes

FXfval ioIndex

Friends

FXAPI FXStreamoperator<< (FXStream &s, QIODevice &i)
FXAPI FXStreamoperator>> (FXStream &s, QIODevice &i)


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:37:38 2009 for TnFOX by doxygen v1.4.7