From 75ce206243e409b170d06723430eb85a4a747882 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Feb 2010 20:47:19 +0100 Subject: move ShowPkg() from apt-get to the PkgIterator and rename it to FullName() responseable for displaying a package name and the architecture in a uniform way. Pretty option can be used to not append the architecture if it is the native architecture or all - and use it all over the place in the commandline tools. --- apt-pkg/cacheiterators.h | 1 + apt-pkg/pkgcache.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 43cbe1377..a64326a44 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -151,6 +151,7 @@ class pkgCache::PkgIterator: public Iterator { //Nice printable representation friend std::ostream& operator <<(std::ostream& out, PkgIterator i); + std::string FullName(bool const &Pretty = false) const; // Constructors inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator(Owner, Trg), HashIndex(0) { diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 29c27b58e..24d9e0329 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -445,6 +445,18 @@ operator<<(ostream& out, pkgCache::PkgIterator Pkg) return out; } /*}}}*/ +// PkgIterator::FullName - Returns Name and (maybe) Architecture /*{{{*/ +// --------------------------------------------------------------------- +/* Returns a name:arch string */ +std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const +{ + string fullname = Name(); + if (Pretty == false || + (strcmp(Arch(), "all") != 0 && _config->Find("APT::Architecture") != Arch())) + return fullname.append(":").append(Arch()); + return fullname; +} + /*}}}*/ // DepIterator::IsCritical - Returns true if the dep is important /*{{{*/ // --------------------------------------------------------------------- /* Currently critical deps are defined as depends, predepends and -- cgit v1.2.3