ArchiveFactory Class | Qt Installer Framework Manual

- Qt Installer Framework Manual
- ArchiveFactory

# ArchiveFactory Class

class QInstaller::ArchiveFactory

The ArchiveFactory class is used to create archive objects based on the suffix of a given filename. More...

Header: | #include <ArchiveFactory>
Inherits: | GenericFactory

- List of all members, including inherited members

## Public Functions

QInstaller::AbstractArchive * | create(const QString &filename, QObject *parent = nullptr) const
void | registerArchive(const QString &name, const QStringList &types)

## Static Public Members

QInstaller::ArchiveFactory & | instance()
bool | isSupportedType(const QString &filename)
QStringList | supportedTypes()

## Detailed Description

This class acts as a factory for `QInstaller::AbstractArchive`. You can register one or more archive handlers with this factory and create registered objects based on the file suffix.

This class follows the singleton design pattern. Only one instance of this class can be created and its reference can be fetched from the `instance()` method.

Depending of the configuration features set at build time, one of the following archive handlers is registered by default:

- Lib7z
- LibArchive

## Member Function Documentation

### QInstaller::AbstractArchive *ArchiveFactory::create(const QString &filename, QObject *parent = nullptr) const

Constructs and returns a pointer to an archive object with filename and parent. If the archive type referenced by filename is not registered, a null pointer is returned instead.

### `[static]` QInstaller::ArchiveFactory &ArchiveFactory::instance()

Returns the only instance of this class.

### `[static]` bool ArchiveFactory::isSupportedType(const QString &filename)

Returns `true` if the archive type from filename is registered with an archive handler.

### template <typename T> void ArchiveFactory::registerArchive(const QString &name, const QStringList &types)

Registers a new archive handler with the factory based on name and list of supported file suffix types.

### `[static]` QStringList ArchiveFactory::supportedTypes()

Returns a list of supported archive types.