#include <QBZip2Device.h>
Inheritance diagram for FX::QBZip2Device:
Much along the lines of FX::QGZipDevice, this takes a QIODevice which accesses the .bz2 file and provides the decompressed version to anything using it. You can use it for reading or writing, though unless seeking is enabled during construction, you may only perform linear reading or writing.
If seeking is enabled, 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 bzipped back to the bz2data source. This obviously implies the usage of RAM to the size of the decompressed data. If you will not be performing any seeking, you can save this memory usage. Note that if seeking is disabled, the following functions do not work or return default values: size(), truncate(), at(FXfval), atEnd(), readBlockFrom(), writeBlockTo(), ungetch().
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 .bz2 data.
On close() or flush() when seeking is enabled, 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!). QBZip2Device never closes the source when you close() it.
You need the bzip2 library available for this to work. If it's missing an exception is generated if you try to use it.
Definition at line 71 of file QBZip2Device.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 | |
QBZip2Device (QIODevice *gzdata=0, int compression=9, bool enableSeeking=true) | |
~QBZip2Device () | |
QIODevice * | BZ2Data () const |
void | setBZ2Data (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) |