#include <QGZipDevice.h>
Inheritance diagram for FX::QGZipDevice:
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.
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.
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 () | |
QIODevice * | GZData () 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 FXACL & | permissions () 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 FXStream & | operator<< (FXStream &s, QIODevice &i) |
FXAPI FXStream & | operator>> (FXStream &s, QIODevice &i) |