+ static bool FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci,
+ pkgCacheFile &Cache, const char * cmdline,
+ std::list<Modifier> const &mods, CacheSetHelper &helper);
+};
+ /*}}}*/
+template<class Container> class PackageContainer : public PackageContainerInterface {/*{{{*/
+/** \class APT::PackageContainer
+
+ Simple wrapper around a container class like std::set to provide a similar
+ interface to a set of packages as to the complete set of all packages in the
+ pkgCache. */
+ Container _cont;
+public: /*{{{*/
+ /** \brief smell like a pkgCache::PkgIterator */
+ class const_iterator : public PackageContainerInterface::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::PkgIterator getPkg(void) const { return *_iter; }
+ inline pkgCache::PkgIterator 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); }
+ };
+ class iterator : public PackageContainerInterface::const_iterator,
+ public std::iterator<std::forward_iterator_tag, typename Container::iterator> {
+ typename Container::iterator _iter;
+ public:
+ iterator(typename Container::iterator i) : _iter(i) {}
+ pkgCache::PkgIterator getPkg(void) const { return *_iter; }
+ inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
+ operator typename Container::iterator(void) const { return _iter; }
+ operator typename PackageContainer<Container>::const_iterator() { return PackageContainer<Container>::const_iterator(_iter); }
+ inline iterator& operator++() { ++_iter; return *this; }
+ inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
+ inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
+ inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+ friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
+ };
+ /*}}}*/
+
+ bool insert(pkgCache::PkgIterator const &P) { if (P.end() == true) return false; _cont.insert(P); return true; };
+ template<class Cont> void insert(PackageContainer<Cont> const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); };
+ void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
+
+ bool empty() const { return _cont.empty(); };
+ void clear() { return _cont.clear(); };
+ void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+ size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
+ void erase(iterator first, iterator last) { _cont.erase(first, last); };
+ size_t size() const { return _cont.size(); };
+
+ const_iterator begin() const { return const_iterator(_cont.begin()); };
+ const_iterator end() const { return const_iterator(_cont.end()); };
+ iterator begin() { return iterator(_cont.begin()); };
+ iterator end() { return iterator(_cont.end()); };
+ const_iterator find(pkgCache::PkgIterator const &P) const { return const_iterator(_cont.find(P)); };
+
+ void setConstructor(Constructor const &by) { ConstructedBy = by; };
+ Constructor getConstructor() const { return ConstructedBy; };
+
+ PackageContainer() : ConstructedBy(UNKNOWN) {};
+ PackageContainer(Constructor const &by) : ConstructedBy(by) {};
+
+ /** \brief returns all packages in the cache who belong to the given task
+
+ A simple helper responsible for search for all members of a task
+ in the cache. Optional it prints a a notice about the
+ packages chosen cause of the given task.
+ \param Cache the packages are in
+ \param pattern name of the task
+ \param helper responsible for error and message handling */
+ static PackageContainer FromTask(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) {
+ PackageContainer cont(TASK);
+ PackageContainerInterface::FromTask(&cont, Cache, pattern, helper);
+ return cont;
+ }
+ static PackageContainer FromTask(pkgCacheFile &Cache, std::string const &pattern) {
+ CacheSetHelper helper;
+ return FromTask(Cache, pattern, helper);
+ }