kio Library: KFilterDev Class Reference (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KFilterDev Class Reference

A class for reading and writing compressed data onto a device (e.g. More...

`#include <kfilterdev.h>`

Inheritance diagram for KFilterDev:

[legend]
Collaboration diagram for KFilterDev:

[legend]
List of all members.

## Public Member Functions
| KFilterDev (KFilterBase *filter, bool autoDeleteFilterBase=false)
virtual | ~KFilterDev ()
virtual bool | open (int mode)
virtual void | close ()
virtual void | flush ()
void | setOrigFileName (const QCString &fileName)
void | setSkipHeaders ()
virtual QIODevice::Offset | size () const
virtual QIODevice::Offset | at () const
virtual bool | at (QIODevice::Offset)
virtual bool | atEnd () const
virtual Q_LONG | readBlock (char *data, Q_ULONG maxlen)
virtual Q_LONG | writeBlock (const char *data, Q_ULONG len)
virtual int | getch ()
virtual int | putch (int)
virtual int | ungetch (int)
## Static Public Member Functions
static QIODevice * | createFilterDevice (KFilterBase *base, QFile *file) KDE_DEPRECATED
static QIODevice * | deviceForFile (const QString &fileName, const QString &mimetype=QString::null, bool forceFilter=false)
static QIODevice * | device (QIODevice *inDevice, const QString &mimetype)
static QIODevice * | device (QIODevice *inDevice, const QString &mimetype, bool autoDeleteInDevice)

## Detailed Description

A class for reading and writing compressed data onto a device (e.g.

file, but other usages are possible, like a buffer or a socket).

To simply read/write compressed files, see deviceForFile.

Author:
  David Faure <faure@kde.org>

Definition at line 36 of file kfilterdev.h.

## Constructor & Destructor Documentation

KFilterDev::KFilterDev | ( | KFilterBase * | filter,
|  | bool | autoDeleteFilterBase = `false`
| ) |

  | Constructs a KFilterDev for a given filter (e.g. gzip, bzip2 etc.). Parameters:
  | filter | the KFilterBase to use
  | autoDeleteFilterBase | when true this object will become the owner of `filter`.
Definition at line 46 of file kfilterdev.cpp. Referenced by createFilterDevice(), device(), and deviceForFile().

KFilterDev::~KFilterDev | ( |  | ) | `[virtual]`

| Destructs the KFilterDev. Calls close() if the filter device is still open. Definition at line 54 of file kfilterdev.cpp. References close(), and QIODevice::isOpen().

## Member Function Documentation

bool KFilterDev::open | ( | int | mode | ) | `[virtual]`

| Open for reading or writing. If the KFilterBase's device is not opened, it will be opened. Reimplemented from QIODevice. Definition at line 119 of file kfilterdev.cpp. References KFilterBase::device(), endl(), KFilterBase::init(), QIODevice::isOpen(), kdWarning(), QIODevice::open(), and KFilterBase::setOutBuffer().

void KFilterDev::close | ( |  | ) | `[virtual]`

| Close after reading or writing. If the KFilterBase's device was opened by open(), it will be closed. Reimplemented from QIODevice. Definition at line 149 of file kfilterdev.cpp. References QIODevice::close(), KFilterBase::device(), QIODevice::isOpen(), KFilterBase::mode(), KFilterBase::terminate(), and QIODevice::writeBlock(). Referenced by ~KFilterDev().

void KFilterDev::setOrigFileName | ( | const QCString & | fileName | ) |

  | For writing gzip compressed files only: set the name of the original file, to be used in the gzip header. Parameters:
  | fileName | the name of the original file
Definition at line 472 of file kfilterdev.cpp.

void KFilterDev::setSkipHeaders | ( |  | ) |

| Call this let this device skip the gzip headers when reading/writing. This way KFilterDev (with gzip filter) can be used as a direct wrapper around zlib - this is used by KZip. Since: 3.1 Definition at line 477 of file kfilterdev.cpp.

bool KFilterDev::at | ( | QIODevice::Offset |  | ) | `[virtual]`

| That one can be quite slow, when going back. Use with care. Definition at line 190 of file kfilterdev.cpp. References QIODevice::at(), KFilterBase::device(), KFilterBase::mode(), QIODevice::readBlock(), QIODevice::reset(), KFilterBase::reset(), and KFilterBase::setInBuffer().

QIODevice * KFilterDev::createFilterDevice | ( | KFilterBase * | base,
|  | QFile * | file
| ) | `[static]`

| Call this to create the appropriate filter device for `base` working on `file` . The returned QIODevice has to be deleted after using. Deprecated: . Use deviceForFile instead. To be removed in KDE 3.0 Definition at line 66 of file kfilterdev.cpp. References KFilterDev().

QIODevice * KFilterDev::deviceForFile | ( | const QString & | fileName,
|  | const QString & | mimetype = `QString::null`,
|  | bool | forceFilter = `false`
| ) | `[static]`

  | Creates an i/o device that is able to read from `fileName`, whether it's compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used. The compression filter to be used is determined from the `fileName` if `mimetype` is empty. Pass "application/x-gzip" or "application/x-bzip2" to force the corresponding decompression filter, if available. Warning: application/x-bzip2 may not be available. In that case a QFile opened on the compressed data will be returned ! Use KFilterBase::findFilterByMimeType and code similar to what deviceForFile is doing, to better control what's happening. The returned QIODevice has to be deleted after using. Parameters:
  | fileName | the name of the file to filter
  | mimetype | the mime type of the file to filter, or QString::null if unknown
  | forceFilter | if true, the function will either find a compression filter, or return 0. If false, it will always return a QIODevice. If no filter is available it will return a simple QFile. This can be useful if the file is usable without a filter.
Returns: if a filter has been found, the QIODevice for the filter. If the filter does not exist, the return value depends on `forceFilter`. The returned QIODevice has to be deleted after using. Definition at line 81 of file kfilterdev.cpp. References KFilterBase::findFilterByFileName(), KFilterBase::findFilterByMimeType(), KFilterDev(), and KFilterBase::setDevice().

QIODevice * KFilterDev::device | ( | QIODevice * | inDevice,
|  | const QString & | mimetype
| ) | `[static]`

  | Creates an i/o device that is able to read from the QIODevice `inDevice`, whether the data is compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used. The compression filter to be used is determined `mimetype` . Pass "application/x-gzip" or "application/x-bzip2" to use the corresponding decompression filter. Warning: application/x-bzip2 may not be available. In that case 0 will be returned ! The returned QIODevice has to be deleted after using. Parameters:
  | inDevice | input device, becomes owned by this device! Automatically deleted!
  | mimetype | the mime type for the filter
Returns: a QIODevice that filters the original stream. Must be deleted after using Definition at line 101 of file kfilterdev.cpp.

QIODevice * KFilterDev::device | ( | QIODevice * | inDevice,
|  | const QString & | mimetype,
|  | bool | autoDeleteInDevice
| ) | `[static]`

  | Creates an i/o device that is able to read from the QIODevice `inDevice`, whether the data is compressed or not. Available compression filters (gzip/bzip2 etc.) will automatically be used. The compression filter to be used is determined `mimetype` . Pass "application/x-gzip" or "application/x-bzip2" to use the corresponding decompression filter. Warning: application/x-bzip2 may not be available. In that case 0 will be returned ! The returned QIODevice has to be deleted after using. Parameters:
  | inDevice | input device. Won't be deleted if `autoDeleteInDevice` = false
  | mimetype | the mime type for the filter
  | autoDeleteInDevice | if true, `inDevice` will be deleted automatically
Returns: a QIODevice that filters the original stream. Must be deleted after using Since: 3.1 Definition at line 106 of file kfilterdev.cpp. References KFilterBase::findFilterByMimeType(), KFilterDev(), and KFilterBase::setDevice().

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

- kfilterdev.h
- kfilterdev.cpp

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:52 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003