Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=cfpm.git;a=commitdiff;h=676713e087555565f2e7427c319ce3d087707fb5
commit 676713e087555565f2e7427c319ce3d087707fb5 Author: Priyank <priy...@frugalware.org> Date: Fri Jun 5 16:14:48 2009 +0530 new class: Package * initial draft diff --git a/pm.cc b/pm.cc index f5b2817..63e0fe2 100644 --- a/pm.cc +++ b/pm.cc @@ -26,8 +26,10 @@ using std::cout; using std::endl; using std::string; + using PM::Shared; using PM::Database; +using PM::Package; bool PM::initialize(const string &root) { @@ -113,3 +115,123 @@ string Database::getName() return name; } +Package::Package() +{ + pkg = NULL; +} + +Package::Package(PM_PKG *p) +{ + pkg = p; +} + +Package::~Package() +{ + free(); +} + +void * Package::getInfo(unsigned char param) +{ + void *ret = NULL; + + if ( !(ret=pacman_pkg_getinfo(pkg,param)) ) + setStatus(); + return ret; +} + +string Package::getName() +{ + string ret = (char*) getInfo(PM_PKG_NAME); + return ret; +} + +string Package::getVersion() +{ + string ret = (char*) getInfo(PM_PKG_VERSION); + return ret; +} + +string Package::getDescription() +{ + string ret = (char*) getInfo(PM_PKG_DESC); + return ret; +} + +string Package::getURL() +{ + string ret = (char*) getInfo(PM_PKG_URL); + return ret; +} + +string Package::getLicense() +{ + string ret = (char*) getInfo(PM_PKG_LICENSE); + return ret; +} + +string Package::getArch() +{ + string ret = (char*) getInfo(PM_PKG_ARCH); + return ret; +} + +string Package::getBuildDate() +{ + string ret = (char*) getInfo(PM_PKG_BUILDDATE); + return ret; +} + +string Package::getBuildType() +{ + string ret = (char*) getInfo(PM_PKG_BUILDTYPE); + return ret; +} + +string Package::getInstallDate() +{ + string ret = (char*) getInfo(PM_PKG_INSTALLDATE); + return ret; +} + +string Package::getPackager() +{ + string ret = (char*) getInfo(PM_PKG_PACKAGER); + return ret; +} + +string Package::getMD5Sum() +{ + string ret = (char*) getInfo(PM_PKG_MD5SUM); + return ret; +} + +string Package::getSHA1Sum() +{ + string ret = (char*) getInfo(PM_PKG_SHA1SUM); + return ret; +} + +int Package::getCompressedSize() +{ + int ret = (int) getInfo(PM_PKG_SIZE); + return ret; +} + +int Package::getUncompressedSize() +{ + int ret = (int) getInfo(PM_PKG_USIZE); + return ret; +} + +int Package::getReason() +{ + int ret = (int) getInfo(PM_PKG_REASON); + return ret; +} + +void Package::free() +{ + if ( pacman_pkg_free(pkg) == -1 ) + setStatus(); +} + diff --git a/pm.hh b/pm.hh index 9e3b744..95c1350 100644 --- a/pm.hh +++ b/pm.hh @@ -35,5 +35,33 @@ namespace PM bool unregisterDb(); bool isRegistered(); }; + + class Package : public Shared + { + PM_PKG *pkg; + + public: + Package(); + Package(PM_PKG *p); + ~Package(); + /* methods to get info about a package */ + void* getInfo(unsigned char param); + std::string getName(); + std::string getVersion(); + std::string getDescription(); + std::string getURL(); + std::string getLicense(); + std::string getArch(); + std::string getBuildDate(); + std::string getBuildType(); + std::string getInstallDate(); + std::string getPackager(); + std::string getMD5Sum(); + std::string getSHA1Sum(); + int getCompressedSize(); + int getUncompressedSize(); + int getReason(); + void free(); + }; } #endif _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git