From d4489d4983d5b9840bb2882a088dd1f363a280b9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 31 May 2010 22:36:41 +0200 Subject: * apt-pkg/cacheset.{cc,h}: - add simple wrapper around std::set for cache structures --- apt-pkg/cacheset.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'apt-pkg/cacheset.h') diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 7c05face6..f0131bfed 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -17,12 +17,12 @@ #include /*}}}*/ namespace APT { +class PackageSet : public std::set { /*{{{*/ /** \class APT::PackageSet Simple wrapper around a std::set to provide a similar interface to a set of packages as to the complete set of all packages in the pkgCache. */ -class PackageSet : public std::set { /*{{{*/ public: /*{{{*/ /** \brief smell like a pkgCache::PkgIterator */ class const_iterator : public std::set::const_iterator { @@ -86,11 +86,54 @@ public: /*{{{*/ std::ostream out (std::ofstream("/dev/null").rdbuf()); return APT::PackageSet::FromCommandLine(Cache, cmdline, out); } + /*}}}*/ +}; /*}}}*/ +class VersionSet : public std::set { /*{{{*/ +/** \class APT::VersionSet + Simple wrapper around a std::set to provide a similar interface to + a set of versions as to the complete set of all versions in the + pkgCache. */ +public: /*{{{*/ + /** \brief smell like a pkgCache::VerIterator */ + class const_iterator : public std::set::const_iterator { + public: + const_iterator(std::set::const_iterator x) : + std::set::const_iterator(x) {} + operator pkgCache::VerIterator(void) { return **this; } + + inline pkgCache *Cache() const { return (**this).Cache(); }; + inline unsigned long Index() const {return (**this).Index();}; + // we have only valid iterators here + inline bool end() const { return false; }; + + inline pkgCache::Version const * operator->() const { + return &***this; + }; + + inline int CompareVer(const pkgCache::VerIterator &B) const { return (**this).CompareVer(B); }; + inline const char *VerStr() const { return (**this).VerStr(); }; + inline const char *Section() const { return (**this).Section(); }; + inline const char *Arch() const { return (**this).Arch(); }; + inline const char *Arch(bool const pseudo) const { return (**this).Arch(pseudo); }; + inline pkgCache::PkgIterator ParentPkg() const { return (**this).ParentPkg(); }; + inline pkgCache::DescIterator DescriptionList() const { return (**this).DescriptionList(); }; + inline pkgCache::DescIterator TranslatedDescription() const { return (**this).TranslatedDescription(); }; + inline pkgCache::DepIterator DependsList() const { return (**this).DependsList(); }; + inline pkgCache::PrvIterator ProvidesList() const { return (**this).ProvidesList(); }; + inline pkgCache::VerFileIterator FileList() const { return (**this).FileList(); }; + inline bool Downloadable() const { return (**this).Downloadable(); }; + inline const char *PriorityType() const { return (**this).PriorityType(); }; + inline string RelStr() const { return (**this).RelStr(); }; + inline bool Automatic() const { return (**this).Automatic(); }; + inline bool Pseudo() const { return (**this).Pseudo(); }; + inline pkgCache::VerFileIterator NewestFile() const { return (**this).NewestFile(); }; + }; + // 103. set::iterator is required to be modifiable, but this allows modification of keys + typedef typename APT::VersionSet::const_iterator iterator; /*}}}*/ -}; - /*}}}*/ +}; /*}}}*/ } #endif -- cgit v1.2.3-70-g09d2