]>
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();};
47 // we have only valid iterators here
48 inline bool end() const { return false; };
50 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, (*i
)); }
52 inline pkgCache::Package
const * operator->() const {
56 // 103. set::iterator is required to be modifiable, but this allows modification of keys
57 typedef typename
APT::PackageSet::const_iterator iterator
;
59 /** \brief returns all packages in the cache whose name matchs a given pattern
61 A simple helper responsible for executing a regular expression on all
62 package names in the cache. Optional it prints a a notice about the
63 packages chosen cause of the given package.
64 \param Cache the packages are in
65 \param pattern regular expression for package names
66 \param out stream to print the notice to */
67 static APT::PackageSet
FromRegEx(pkgCache
&Cache
, std::string pattern
, std::ostream
&out
);
68 static APT::PackageSet
FromRegEx(pkgCache
&Cache
, std::string
const &pattern
) {
69 std::ostream
out (std::ofstream("/dev/null").rdbuf());
70 return APT::PackageSet::FromRegEx(Cache
, pattern
, out
);
73 /** \brief returns all packages specified on the commandline
75 Get all package names from the commandline and executes regex's if needed.
76 No special package command is supported, just plain names.
77 \param Cache the packages are in
78 \param cmdline Command line the package names should be extracted from
79 \param out stream to print various notices to */
80 static APT::PackageSet
FromCommandLine(pkgCache
&Cache
, const char **cmdline
, std::ostream
&out
);
81 static APT::PackageSet
FromCommandLine(pkgCache
&Cache
, const char **cmdline
) {
82 std::ostream
out (std::ofstream("/dev/null").rdbuf());
83 return APT::PackageSet::FromCommandLine(Cache
, cmdline
, out
);