+ enum APT_DEPRECATED Version {
+ ALL = CacheSetHelper::ALL,
+ CANDANDINST = CacheSetHelper::CANDANDINST,
+ CANDIDATE = CacheSetHelper::CANDIDATE,
+ INSTALLED = CacheSetHelper::INSTALLED,
+ CANDINST = CacheSetHelper::CANDINST,
+ INSTCAND = CacheSetHelper::INSTCAND,
+ NEWEST = CacheSetHelper::NEWEST
+ };
+
+ struct Modifier {
+ unsigned short const ID;
+ const char * const Alias;
+ enum Position { NONE, PREFIX, POSTFIX } const Pos;
+ enum CacheSetHelper::VerSelector const SelectVersion;
+ Modifier (unsigned short const &id, const char * const alias, Position const &pos,
+ enum CacheSetHelper::VerSelector const select) : ID(id), Alias(alias), Pos(pos),
+ SelectVersion(select) {}
+APT_IGNORE_DEPRECATED_PUSH
+ APT_DEPRECATED Modifier(unsigned short const &id, const char * const alias, Position const &pos,
+ Version const &select) : ID(id), Alias(alias), Pos(pos),
+ SelectVersion((CacheSetHelper::VerSelector)select) {}
+APT_IGNORE_DEPRECATED_POP
+ };
+
+ static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ const char **cmdline, CacheSetHelper::VerSelector const fallback,
+ CacheSetHelper &helper);
+APT_IGNORE_DEPRECATED_PUSH
+ APT_DEPRECATED static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ const char **cmdline, Version const &fallback,
+ CacheSetHelper &helper) {
+ return FromCommandLine(vci, Cache, cmdline, (CacheSetHelper::VerSelector)fallback, helper);
+ }
+APT_IGNORE_DEPRECATED_POP
+
+ static bool FromString(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ std::string pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper,
+ bool const onlyFromName = false);
+APT_IGNORE_DEPRECATED_PUSH
+ APT_DEPRECATED static bool FromString(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ std::string pkg, Version const &fallback, CacheSetHelper &helper,
+ bool const onlyFromName = false) {
+ return FromString(vci, Cache, pkg, (CacheSetHelper::VerSelector)fallback, helper, onlyFromName);
+ }
+APT_IGNORE_DEPRECATED_POP
+
+ static bool FromPackage(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &P, CacheSetHelper::VerSelector const fallback,
+ CacheSetHelper &helper);
+APT_IGNORE_DEPRECATED_PUSH
+ APT_DEPRECATED static bool FromPackage(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &P, Version const &fallback,
+ CacheSetHelper &helper) {
+ return FromPackage(vci, Cache, P, (CacheSetHelper::VerSelector)fallback, helper);
+ }
+APT_IGNORE_DEPRECATED_POP
+
+ 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,
+ CacheSetHelper::VerSelector const selector,
+ CacheSetHelper &helper);
+APT_IGNORE_DEPRECATED_PUSH
+ APT_DEPRECATED static bool FromDependency(VersionContainerInterface * const vci,
+ pkgCacheFile &Cache,
+ pkgCache::DepIterator const &D,
+ Version const &selector,
+ CacheSetHelper &helper) {
+ return FromDependency(vci, Cache, D, (CacheSetHelper::VerSelector)selector, helper);
+ }
+APT_IGNORE_DEPRECATED_POP
+
+ VersionContainerInterface();
+ virtual ~VersionContainerInterface();
+private:
+ void *d;
+
+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
+ pkgCache. */
+ Container _cont;
+public: /*{{{*/
+ /** \brief smell like a pkgCache::VerIterator */
+ class const_iterator : public VersionContainerInterface::const_iterator,
+ public std::iterator<std::forward_iterator_tag, typename Container::const_iterator> {/*{{{*/
+ typename Container::const_iterator _iter;
+ public:
+ const_iterator(typename Container::const_iterator i) : _iter(i) {}
+ pkgCache::VerIterator getVer(void) const { return *_iter; }
+ inline pkgCache::VerIterator operator*(void) const { return *_iter; }
+ operator typename Container::const_iterator(void) const { return _iter; }
+ inline const_iterator& operator++() { ++_iter; return *this; }
+ inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
+ inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; }
+ inline bool operator==(const_iterator const &i) const { return _iter == i._iter; }
+ friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }