+template<> template<class Cont> void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(PackageContainer<Cont> const &pkgcont) {
+ for (typename PackageContainer<Cont>::const_iterator p = pkgcont.begin(); p != pkgcont.end(); ++p)
+ _cont.push_back(*p);
+}
+// these two are 'inline' as otherwise the linker has problems with seeing these untemplated
+// specializations again and again - but we need to see them, so that library users can use them
+template<> inline bool PackageContainer<std::list<pkgCache::PkgIterator> >::insert(pkgCache::PkgIterator const &P) {
+ if (P.end() == true)
+ return false;
+ _cont.push_back(P);
+ return true;
+}
+template<> inline void PackageContainer<std::list<pkgCache::PkgIterator> >::insert(const_iterator begin, const_iterator end) {
+ for (const_iterator p = begin; p != end; ++p)
+ _cont.push_back(*p);
+}
+typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet;
+typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList;
+
+class VersionContainerInterface { /*{{{*/
+/** \class APT::VersionContainerInterface
+
+ Same as APT::PackageContainerInterface, just for Versions */
+public:
+ /** \brief smell like a pkgCache::VerIterator */
+ class const_iterator { /*{{{*/
+ public:
+ virtual pkgCache::VerIterator getVer() const = 0;
+ operator pkgCache::VerIterator(void) { return getVer(); }
+
+ inline pkgCache *Cache() const { return getVer().Cache(); }
+ inline unsigned long Index() const {return getVer().Index();}
+ inline int CompareVer(const pkgCache::VerIterator &B) const { return getVer().CompareVer(B); }
+ inline const char *VerStr() const { return getVer().VerStr(); }
+ inline const char *Section() const { return getVer().Section(); }
+ inline const char *Arch() const { return getVer().Arch(); }
+ inline pkgCache::PkgIterator ParentPkg() const { return getVer().ParentPkg(); }
+ inline pkgCache::DescIterator DescriptionList() const { return getVer().DescriptionList(); }
+ inline pkgCache::DescIterator TranslatedDescription() const { return getVer().TranslatedDescription(); }
+ inline pkgCache::DepIterator DependsList() const { return getVer().DependsList(); }
+ inline pkgCache::PrvIterator ProvidesList() const { return getVer().ProvidesList(); }
+ inline pkgCache::VerFileIterator FileList() const { return getVer().FileList(); }
+ inline bool Downloadable() const { return getVer().Downloadable(); }
+ inline const char *PriorityType() const { return getVer().PriorityType(); }
+ inline std::string RelStr() const { return getVer().RelStr(); }
+ inline bool Automatic() const { return getVer().Automatic(); }
+ inline pkgCache::VerFileIterator NewestFile() const { return getVer().NewestFile(); }
+ // we have only valid iterators here
+ inline bool end() const { return false; }
+
+ inline pkgCache::Version const * operator->() const { return &*getVer(); }
+ };
+ /*}}}*/
+
+ virtual bool insert(pkgCache::VerIterator const &V) = 0;
+ virtual bool empty() const = 0;
+ virtual void clear() = 0;
+
+ /** \brief specifies which version(s) will be returned if non is given */
+ enum Version {
+ /** All versions */
+ ALL,
+ /** Candidate and installed version */
+ CANDANDINST,
+ /** Candidate version */
+ CANDIDATE,
+ /** Installed version */
+ INSTALLED,
+ /** Candidate or if non installed version */
+ CANDINST,
+ /** Installed or if non candidate version */
+ INSTCAND,
+ /** Newest version */
+ NEWEST
+ };
+
+ struct Modifier {
+ enum Position { NONE, PREFIX, POSTFIX };
+ unsigned short ID;
+ const char * const Alias;
+ Position Pos;
+ Version SelectVersion;
+ Modifier (unsigned short const &id, const char * const alias, Position const &pos,
+ Version const &select) : ID(id), Alias(alias), Pos(pos),
+ SelectVersion(select) {}
+ };
+
+ static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ const char **cmdline, Version const &fallback,
+ CacheSetHelper &helper);
+
+ static bool FromString(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ std::string pkg, Version const &fallback, CacheSetHelper &helper,
+ bool const onlyFromName = false);
+
+ static bool FromPackage(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &P, Version const &fallback,
+ CacheSetHelper &helper);
+
+ static bool FromModifierCommandLine(unsigned short &modID,
+ VersionContainerInterface * const vci,
+ pkgCacheFile &Cache, const char * cmdline,
+ std::list<Modifier> const &mods,
+ CacheSetHelper &helper);
+
+
+ static bool FromDependency(VersionContainerInterface * const vci,
+ pkgCacheFile &Cache,
+ pkgCache::DepIterator const &D,
+ Version const &selector,
+ CacheSetHelper &helper);
+
+protected: /*{{{*/
+
+ /** \brief returns the candidate version of the package
+
+ \param Cache to be used to query for information
+ \param Pkg we want the candidate version from this package
+ \param helper used in this container instance */
+ static pkgCache::VerIterator getCandidateVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
+
+ /** \brief returns the installed version of the package
+
+ \param Cache to be used to query for information
+ \param Pkg we want the installed version from this package
+ \param helper used in this container instance */
+ static pkgCache::VerIterator getInstalledVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper);
+ /*}}}*/
+};
+ /*}}}*/
+template<class Container> class VersionContainer : public VersionContainerInterface {/*{{{*/
+/** \class APT::VersionContainer
+
+ Simple wrapper around a container class like std::set to provide a similar
+ interface to a set of versions as to the complete set of all versions in the