109 lines
2.4 KiB
C++
109 lines
2.4 KiB
C++
#ifndef PACKAGEMANAGEMENT_ALPMPACKAGE_H
|
|
#define PACKAGEMANAGEMENT_ALPMPACKAGE_H
|
|
|
|
#include "package.h"
|
|
|
|
namespace PackageManagement {
|
|
|
|
class AlpmDataBase;
|
|
|
|
class AlpmPackage : public Package
|
|
{
|
|
public:
|
|
AlpmPackage(alpm_pkg_t *package, AlpmDataBase *source = nullptr);
|
|
|
|
// ALPM specific meta data
|
|
const alpm_pkg_t *ptr() const;
|
|
alpm_pkg_t *ptr();
|
|
const char *base64Signature() const;
|
|
void *openChangelog() const;
|
|
size_t readChangelog(void *changelog, void *buffer, size_t bufferSize);
|
|
bool closeChangelog(void *changelog);
|
|
|
|
protected:
|
|
alpm_pkg_t *m_ptr;
|
|
};
|
|
|
|
inline uint qHash(const AlpmPackage &key)
|
|
{
|
|
return qHash(key.ptr());
|
|
}
|
|
|
|
/*!
|
|
* \brief Returns a pointer to the underlying alpm_pkg_t.
|
|
*/
|
|
inline const alpm_pkg_t *AlpmPackage::ptr() const
|
|
{
|
|
return m_ptr;
|
|
}
|
|
|
|
/*!
|
|
* \brief Returns a pointer to the underlying alpm_pkg_t.
|
|
*/
|
|
inline alpm_pkg_t *AlpmPackage::ptr()
|
|
{
|
|
return m_ptr;
|
|
}
|
|
|
|
inline const char *AlpmPackage::base64Signature() const
|
|
{
|
|
return alpm_pkg_get_base64_sig(m_ptr);
|
|
}
|
|
|
|
inline void *AlpmPackage::openChangelog() const
|
|
{
|
|
return alpm_pkg_changelog_open(m_ptr);
|
|
}
|
|
|
|
inline size_t AlpmPackage::readChangelog(void *changelog, void *buffer, size_t bufferSize)
|
|
{
|
|
return alpm_pkg_changelog_read(buffer, bufferSize, m_ptr, changelog);
|
|
}
|
|
|
|
inline bool AlpmPackage::closeChangelog(void *changelog)
|
|
{
|
|
return alpm_pkg_changelog_close(m_ptr, changelog);
|
|
}
|
|
|
|
class AlpmOwnershipPackage : public AlpmPackage
|
|
{
|
|
public:
|
|
// constructor, destructor
|
|
AlpmOwnershipPackage(alpm_pkg_t *package);
|
|
AlpmOwnershipPackage(const AlpmOwnershipPackage &other) = delete;
|
|
AlpmOwnershipPackage(AlpmOwnershipPackage &&other);
|
|
~AlpmOwnershipPackage();
|
|
|
|
// assignment operator
|
|
AlpmOwnershipPackage &operator =(const AlpmOwnershipPackage &other) = delete;
|
|
AlpmOwnershipPackage &operator =(AlpmOwnershipPackage &&other);
|
|
};
|
|
|
|
inline AlpmOwnershipPackage::AlpmOwnershipPackage(alpm_pkg_t *package) :
|
|
AlpmPackage(package)
|
|
{}
|
|
|
|
inline AlpmOwnershipPackage::AlpmOwnershipPackage(AlpmOwnershipPackage &&other) :
|
|
AlpmPackage(other.m_ptr)
|
|
{
|
|
other.m_ptr = nullptr;
|
|
}
|
|
|
|
inline AlpmOwnershipPackage &AlpmOwnershipPackage::operator =(AlpmOwnershipPackage &&other)
|
|
{
|
|
if(this != &other) {
|
|
m_ptr = other.m_ptr;
|
|
other.m_ptr = nullptr;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
inline AlpmOwnershipPackage::~AlpmOwnershipPackage()
|
|
{
|
|
alpm_pkg_free(ptr());
|
|
}
|
|
|
|
} // namespace PackageManagement
|
|
|
|
#endif // PACKAGEMANAGEMENT_ALPMPACKAGE_H
|