Metadata Class | Qt Installer Framework Manual

- Qt Installer Framework Manual
- Metadata

# Metadata Class

class QInstaller::Metadata

The Metadata class represents fetched metadata from a repository. More...

Header: | #include <Metadata>
Inherits: | QInstaller::CacheableItem

- List of all members, including inherited members

## Public Functions

| Metadata()
| Metadata(const QString &path)
bool | containsRepositoryUpdates() const
bool | isAvailableFromDefaultRepository() const
QString | persistentRepositoryPath()
QInstaller::Repository | repository() const
void | setAvailableFromDefaultRepository(bool defaultRepository)
void | setChecksum(const QByteArray &checksum)
void | setPersistentRepositoryPath(const QUrl &url)
void | setRepository(const QInstaller::Repository &repository)
QDomDocument | updatesDocument() const

## Reimplemented Public Functions

virtual QByteArray | checksum() const override
virtual bool | isActive() const override
virtual bool | isValid() const override
virtual bool | obsoletes(QInstaller::CacheableItem *other) override

## Detailed Description

## Member Function Documentation

### Metadata::Metadata()

Constructs a new metadata object.

### `[explicit]` Metadata::Metadata(const QString &path)

Constructs a new metadata object with a path.

### `[override virtual]` QByteArray Metadata::checksum() const

Reimplements: CacheableItem::checksum() const.

Returns the checksum of this metadata which is the checksum of the Updates.xml file. The checksum value is stored to memory after first read, so a single object should not be reused for referring other metadata.

See also setChecksum().

### bool Metadata::containsRepositoryUpdates() const

Returns true if the updates document of this metadata contains the repository update element, which can include actions to `add`, `remove`, and `replace` repositories.

Note: This function does not check that the repository updates are actually valid, only that the updates document contains the `RepositoryUpdate` element.

### `[override virtual]` bool Metadata::isActive() const

Reimplements: CacheableItem::isActive() const.

Returns `true` if this metadata is active, `false` otherwise. Metadata is considered active if it is currently associated with a valid repository.

### bool Metadata::isAvailableFromDefaultRepository() const

Returns `true` if this metadata is available from a default repository, which means a repository without category, `false` otherwise.

### `[override virtual]` bool Metadata::isValid() const

Reimplements: CacheableItem::isValid() const.

Returns `true` if the `Updates.xml` document of this metadata exists, and that all meta files referenced in the document exist. If the `Updates.xml` contains a `Checksum` element with a value of `true`, the integrity of the files is also verified.

Returns `false` otherwise.

### `[override virtual]` bool Metadata::obsoletes(QInstaller::CacheableItem *other)

Reimplements: CacheableItem::obsoletes(QInstaller::CacheableItem *other).

Checks whether this metadata object obsoletes the other metadata. The other metadata is considered obsolete if it is not currently associated with any repository, and the URL of the calling metadata matches the last known URL of the other metadata. Returns `true` if the current metadata obsoletes the other, `false` otherwise.

### QString Metadata::persistentRepositoryPath()

Returns the persistent repository path of the metadata.

See also setPersistentRepositoryPath().

### QInstaller::Repository Metadata::repository() const

Returns the repository object set for this metadata. This is the repository the metadata is currently associated with, which may be different from the repository where it was originally fetched.

See also setRepository().

### void Metadata::setAvailableFromDefaultRepository(bool defaultRepository)

Sets the metadata available from a default repository based on the value of defaultRepository. This is not mutually exclusive from a metadata that has repository categories set.

See also isAvailableFromDefaultRepository().

### void Metadata::setChecksum(const QByteArray &checksum)

Sets the checksum of this metadata to checksum. Calling this function will omit calculating the checksum from the update file when retrieving the checksum with checksum() for the first time.

See also checksum().

### void Metadata::setPersistentRepositoryPath(const QUrl &url)

Sets the repository path of this metadata from url, without the protocol or hostname. Unlike setRepository() this value is saved to disk, which allows retrieving the repository path of the metadata on later runs.

See also persistentRepositoryPath().

### void Metadata::setRepository(const QInstaller::Repository &repository)

Sets the repository object of this metadata. If a repository is already set, the new one will override the previous one. The metadata becomes associated with the set repository even if it was fetched from another one.

See also repository().

### QDomDocument Metadata::updatesDocument() const

Returns the root of the document tree representing the `Updates.xml` document of this metadata. Returns an empty `QDomDocument` in case of failure to reading the file.