kio Library: KURIFilter Class Reference (kio Library)

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

# KURIFilter Class Reference

Manages the filtering of URIs. Filters a given URL into its proper format whenever possible. More...

`#include <kurifilter.h>`

Collaboration diagram for KURIFilter:

[legend]
List of all members.

## Public Member Functions
| ~KURIFilter ()
bool | filterURI (KURIFilterData &data, const QStringList &filters=QStringList())
bool | filterURI (KURL &uri, const QStringList &filters=QStringList())
bool | filterURI (QString &uri, const QStringList &filters=QStringList())
KURL | filteredURI (const KURL &uri, const QStringList &filters=QStringList())
QString | filteredURI (const QString &uri, const QStringList &filters=QStringList())
QPtrListIterator< KURIFilterPlugin > | pluginsIterator () const
QStringList | pluginNames () const
## Static Public Member Functions
static KURIFilter * | self ()
## Protected Member Functions
| KURIFilter ()
void | loadPlugins ()

## Detailed Description

Manages the filtering of URIs. Filters a given URL into its proper format whenever possible.

The intention of this plugin class is to allow people to extend the functionality of KURL without modifying it directly. This way KURL will remain a generic parser capable of parsing any generic URL that adheres to specifications.

The KURIFilter class applies a number of filters to a URI and returns the filtered version whenever possible. The filters are implemented using plugins to provide easy extensibility of the filtering mechanism. New filters can be added in the future by simply inheriting from KURIFilterPlugin and implementing the KURIFilterPlugin::filterURI method.

Use of this plugin-manager class is straight forward. Since it is a singleton object, all you have to do is obtain an instance by doing `KURIFilter::self()` and use any of the public member functions to preform the filtering.

Example

To simply filter a given string:

     bool filtered = KURIFilter::self()->filterURI( "kde.org" );

You can alternatively use a KURL:

     KURL url = "kde.org";
     bool filtered = KURIFilter::self()->filterURI( url );

If you have a constant string or a constant URL, simply invoke the corresponding function to obtain the filtered string or URL instead of a boolean flag:

     QString u = KURIFilter::self()->filteredURI( "kde.org" );

You can also restrict the filter(s) to be used by supplying the name of the filter(s) to use. By defualt all available filters will be used. To use specific filters, add the names of the filters you want to use to a QStringList and invoke the appropriate filtering function. The examples below show the use of specific filters. The first one uses a single filter called kshorturifilter while the second example uses multiple filters:

     QString text = "kde.org";
     bool filtered = KURIFilter::self()->filterURI( text, "kshorturifilter" );

     QStringList list;
     list << "kshorturifilter" << "localdomainfilter";
     bool filtered = KURIFilter::self()->filterURI( text, list );

KURIFilter also allows richer data exchange through a simple meta-object called `KURIFilterData`. Using this meta-object you can find out more information about the URL you want to filter. See KURIFilterData for examples and details.

Definition at line 528 of file kurifilter.h.

## Constructor & Destructor Documentation

KURIFilter::~KURIFilter | ( |  | ) |

| Destructor. Definition at line 222 of file kurifilter.cpp.

KURIFilter::KURIFilter | ( |  | ) | `[protected]`

| A protected constructor. This constructor creates a KURIFilter and initializes all plugins it can find by invoking loadPlugins. Definition at line 216 of file kurifilter.cpp. References loadPlugins(), and QPtrList::setAutoDelete().

## Member Function Documentation

KURIFilter * KURIFilter::self | ( |  | ) | `[static]`

| Returns an instance of KURIFilter. Definition at line 209 of file kurifilter.cpp. References KStaticDeleter< type >::setObject().

bool KURIFilter::filterURI | ( | KURIFilterData & | data,
|  | const QStringList & | filters = `QStringList()`
| ) |

  | Filters the URI given by the object URIFilterData. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used. Parameters:
  | data | object that contains the URI to be filtered.
  | filters | specify the list of filters to be used.
Returns: a boolean indicating whether the URI has been changed Definition at line 227 of file kurifilter.cpp. References QPtrList::append(), and QPtrListIterator::current(). Referenced by filteredURI(), and filterURI().

bool KURIFilter::filterURI | ( | KURL & | uri,
|  | const QStringList & | filters = `QStringList()`
| ) |

  | Filters the URI given by the URL. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used. Parameters:
  | uri | the URI to filter.
  | filters | specify the list of filters to be used.
Returns: a boolean indicating whether the URI has been changed Definition at line 265 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri().

bool KURIFilter::filterURI | ( | QString & | uri,
|  | const QStringList & | filters = `QStringList()`
| ) |

  | Filters a string representing a URI. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used. Parameters:
  | uri | The URI to filter.
  | filters | specify the list of filters to be used.
Returns: a boolean indicating whether the URI has been changed Definition at line 273 of file kurifilter.cpp. References filterURI(), KURIFilterData::uri(), and KURL::url().

KURL KURIFilter::filteredURI | ( | const KURL & | uri,
|  | const QStringList & | filters = `QStringList()`
| ) |

  | Returns the filtered URI. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used. Parameters:
  | uri | The URI to filter.
  | filters | specify the list of filters to be used.
Returns: the filtered URI or null if it cannot be filtered Definition at line 282 of file kurifilter.cpp. References filterURI(), and KURIFilterData::uri().

QString KURIFilter::filteredURI | ( | const QString & | uri,
|  | const QStringList & | filters = `QStringList()`
| ) |

  | Return a filtered string representation of a URI. The given URL is filtered based on the specified list of filters. If the list is empty all available filters would be used. Parameters:
  | uri | the URI to filter.
  | filters | specify the list of filters to be used.
Returns: the filtered URI or null if it cannot be filtered Definition at line 289 of file kurifilter.cpp. References filterURI(), KURIFilterData::uri(), and KURL::url().

QPtrListIterator< KURIFilterPlugin > KURIFilter::pluginsIterator | ( |  | ) | const

| Return an iterator to iterate over all loaded plugins. Returns: a plugin iterator. Definition at line 296 of file kurifilter.cpp. Referenced by pluginNames().

QStringList KURIFilter::pluginNames | ( |  | ) | const

| Return a list of the names of all loaded plugins. Returns: a QStringList of plugin names Since: 3.1 Definition at line 301 of file kurifilter.cpp. References pluginsIterator().

void KURIFilter::loadPlugins | ( |  | ) | `[protected]`

| Loads all allowed plugins. This function loads all filters that have not been disbled. Definition at line 309 of file kurifilter.cpp. References QPtrList::append(), QValueList::begin(), QValueList::end(), KTrader::query(), and KTrader::self(). Referenced by KURIFilter().

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

- kurifilter.h
- kurifilter.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:25:30 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003