#ifndef ALPM_DATABASE_H #define ALPM_DATABASE_H #include "repository.h" #include "list.h" #include #include namespace PackageManagement { class AlpmDataBase : public Repository { public: explicit AlpmDataBase(alpm_db_t *dataBase, const QString &dbPath, QObject *parent = nullptr); // explicit AlpmDataBase(const QString &dataBaseFile, QObject *parent = nullptr); RepositoryType type() const; bool isSourceOnly() const; // operators bool operator ==(const AlpmDataBase &other) const; bool operator !=(const AlpmDataBase &other) const; // database meta data alpm_db_t *ptr(); const QString &dataBaseFile() const; StringList servers() const; bool setServers(StringList servers); bool addServerUrls(const QStringList &urls); PackageList search(StringList terms) const; private: alpm_db_t *m_ptr; QString m_dbFile; }; /*! * \brief Checks whether the specified ALPM database is equal the current instance. */ inline bool AlpmDataBase::operator ==(const AlpmDataBase &other) const { return m_ptr == other.m_ptr; } /*! * \brief Checks whether the specified ALPM database is not equal to the current instance. */ inline bool AlpmDataBase::operator !=(const AlpmDataBase &other) const { return m_ptr != other.m_ptr; } /*! * \brief Returns the pointer to the underlying database struct. */ inline alpm_db_t *AlpmDataBase::ptr() { return m_ptr; } /*! * \brief Returns the path of the data base file. */ inline const QString &AlpmDataBase::dataBaseFile() const { return m_dbFile; } /*! * \brief Returns the servers of the database. */ inline StringList AlpmDataBase::servers() const { return alpm_db_get_servers(m_ptr); } /*! * \brief Sets the servers of the database. */ inline bool AlpmDataBase::setServers(StringList servers) { return alpm_db_set_servers(m_ptr, servers.begin().ptr()) == 0; } /*! * \brief Performs a search using the build in ALPM function. */ inline PackageList AlpmDataBase::search(StringList terms) const { return alpm_db_search(m_ptr, terms.begin().ptr()); } } // namespace Alpm #endif // ALPM_DATABASE_H