]>
git.saurik.com Git - apt.git/blob - apt-pkg/packageset.h
1 // -*- mode: cpp; mode: fold -*-
3 /** \class APT::PackageSet
5 Simple wrapper around a std::set to provide a similar interface to
6 a set of packages as to the complete set of all packages in the
10 #ifndef APT_PACKAGESET_H
11 #define APT_PACKAGESET_H
12 // Include Files /*{{{*/
18 #include <apt-pkg/pkgcache.h>
21 class PackageSet
: public std::set
<pkgCache::PkgIterator
> { /*{{{*/
23 /** \brief smell like a pkgCache::PkgIterator */
24 class const_iterator
: public std::set
<pkgCache::PkgIterator
>::const_iterator
{
26 const_iterator(std::set
<pkgCache::PkgIterator
>::const_iterator x
) :
27 std::set
<pkgCache::PkgIterator
>::const_iterator(x
) {}
29 operator pkgCache::PkgIterator(void) { return **this; }
31 inline const char *Name() const {return (*this)->Name(); }
32 inline std::string
FullName(bool const &Pretty
) const { return (*this)->FullName(Pretty
); }
33 inline std::string
FullName() const { return (*this)->FullName(); }
34 inline const char *Section() const {return (*this)->Section(); }
35 inline bool Purge() const {return (*this)->Purge(); }
36 inline const char *Arch() const {return (*this)->Arch(); }
37 inline pkgCache::GrpIterator
Group() const { return (*this)->Group(); }
38 inline pkgCache::VerIterator
VersionList() const { return (*this)->VersionList(); }
39 inline pkgCache::VerIterator
CurrentVer() const { return (*this)->CurrentVer(); }
40 inline pkgCache::DepIterator
RevDependsList() const { return (*this)->RevDependsList(); }
41 inline pkgCache::PrvIterator
ProvidesList() const { return (*this)->ProvidesList(); }
42 inline pkgCache::PkgIterator::OkState
State() const { return (*this)->State(); }
43 inline const char *CandVersion() const { return (*this)->CandVersion(); }
44 inline const char *CurVersion() const { return (*this)->CurVersion(); }
45 inline pkgCache
*Cache() const { return (*this)->Cache(); };
46 inline unsigned long Index() const {return (*this)->Index();};
48 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, (*i
)); }
50 inline pkgCache::PkgIterator
const * operator->() const {
54 // 103. set::iterator is required to be modifiable, but this allows modification of keys
55 typedef typename
APT::PackageSet::const_iterator iterator
;
57 /** \brief returns all packages in the cache whose name matchs a given pattern
59 A simple helper responsible for executing a regular expression on all
60 package names in the cache. Optional it prints a a notice about the
61 packages chosen cause of the given package.
62 \param Cache the packages are in
63 \param pattern regular expression for package names
64 \param out stream to print the notice to */
65 static APT::PackageSet
FromRegEx(pkgCache
&Cache
, const char *pattern
, std::ostream
&out
);
66 static APT::PackageSet
FromRegEx(pkgCache
&Cache
, const char *pattern
) {
67 std::ostream
out (std::ofstream("/dev/null").rdbuf());
68 return APT::PackageSet::FromRegEx(Cache
, pattern
, out
);