#ifndef ALPM_DATABASE_H #define ALPM_DATABASE_H #include "./repository.h" #include "./list.h" #include #include #include #include namespace RepoIndex { class AlpmPackage; class AlpmDatabase; class AlpmPackageLoader : public PackageLoader { public: AlpmPackageLoader(AlpmDatabase *db); private: QList m_packages; }; class AlpmDatabase : public Repository { public: explicit AlpmDatabase(alpm_db_t *dataBase, const QString &dbPath, uint32 index = invalidIndex, QObject *parent = nullptr); AlpmPackageLoader *init(); // explicit AlpmDatabase(const QString &dataBaseFile, QObject *parent = nullptr); RepositoryType type() const; PackageDetailAvailability requestsRequired(PackageDetail packageDetail) 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; signals: void initiated(); 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