]>
git.saurik.com Git - apt.git/blob - apt-pkg/cacheset.h
1 // -*- mode: cpp; mode: fold -*-
4 Wrappers around std::set to have set::iterators which behave
5 similar to the Iterators of the cache structures.
7 Provides also a few helper methods which work with these sets */
10 #define APT_CACHESET_H
11 // Include Files /*{{{*/
17 #include <apt-pkg/pkgcache.h>
20 class PackageSet
: public std::set
<pkgCache::PkgIterator
> { /*{{{*/
21 /** \class APT::PackageSet
23 Simple wrapper around a std::set to provide a similar interface to
24 a set of packages as to the complete set of all packages in the
27 /** \brief smell like a pkgCache::PkgIterator */
28 class const_iterator
: public std::set
<pkgCache::PkgIterator
>::const_iterator
{
30 const_iterator(std::set
<pkgCache::PkgIterator
>::const_iterator x
) :
31 std::set
<pkgCache::PkgIterator
>::const_iterator(x
) {}
33 operator pkgCache::PkgIterator(void) { return **this; }
35 inline const char *Name() const {return (**this).Name(); }
36 inline std::string
FullName(bool const &Pretty
) const { return (**this).FullName(Pretty
); }
37 inline std::string
FullName() const { return (**this).FullName(); }
38 inline const char *Section() const {return (**this).Section(); }
39 inline bool Purge() const {return (**this).Purge(); }
40 inline const char *Arch() const {return (**this).Arch(); }
41 inline pkgCache::GrpIterator
Group() const { return (**this).Group(); }
42 inline pkgCache::VerIterator
VersionList() const { return (**this).VersionList(); }
43 inline pkgCache::VerIterator
CurrentVer() const { return (**this).CurrentVer(); }
44 inline pkgCache::DepIterator
RevDependsList() const { return (**this).RevDependsList(); }
45 inline pkgCache::PrvIterator
ProvidesList() const { return (**this).ProvidesList(); }
46 inline pkgCache::PkgIterator::OkState
State() const { return (**this).State(); }
47 inline const char *CandVersion() const { return (**this).CandVersion(); }
48 inline const char *CurVersion() const { return (**this).CurVersion(); }
49 inline pkgCache
*Cache() const { return (**this).Cache(); };
50 inline unsigned long Index() const {return (**this).Index();};
51 // we have only valid iterators here
52 inline bool end() const { return false; };
54 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, (*i
)); }
56 inline pkgCache::Package
const * operator->() const {
60 // 103. set::iterator is required to be modifiable, but this allows modification of keys
61 typedef typename
APT::PackageSet::const_iterator iterator
;
63 /** \brief returns all packages in the cache whose name matchs a given pattern
65 A simple helper responsible for executing a regular expression on all
66 package names in the cache. Optional it prints a a notice about the
67 packages chosen cause of the given package.
68 \param Cache the packages are in
69 \param pattern regular expression for package names
70 \param out stream to print the notice to */
71 static APT::PackageSet
FromRegEx(pkgCache
&Cache
, std::string pattern
, std::ostream
&out
);
72 static APT::PackageSet
FromRegEx(pkgCache
&Cache
, std::string
const &pattern
) {
73 std::ostream
out (std::ofstream("/dev/null").rdbuf());
74 return APT::PackageSet::FromRegEx(Cache
, pattern
, out
);
77 /** \brief returns all packages specified on the commandline
79 Get all package names from the commandline and executes regex's if needed.
80 No special package command is supported, just plain names.
81 \param Cache the packages are in
82 \param cmdline Command line the package names should be extracted from
83 \param out stream to print various notices to */
84 static APT::PackageSet
FromCommandLine(pkgCache
&Cache
, const char **cmdline
, std::ostream
&out
);
85 static APT::PackageSet
FromCommandLine(pkgCache
&Cache
, const char **cmdline
) {
86 std::ostream
out (std::ofstream("/dev/null").rdbuf());
87 return APT::PackageSet::FromCommandLine(Cache
, cmdline
, out
);
91 class VersionSet
: public std::set
<pkgCache::VerIterator
> { /*{{{*/
92 /** \class APT::VersionSet
94 Simple wrapper around a std::set to provide a similar interface to
95 a set of versions as to the complete set of all versions in the
98 /** \brief smell like a pkgCache::VerIterator */
99 class const_iterator
: public std::set
<pkgCache::VerIterator
>::const_iterator
{
101 const_iterator(std::set
<pkgCache::VerIterator
>::const_iterator x
) :
102 std::set
<pkgCache::VerIterator
>::const_iterator(x
) {}
104 operator pkgCache::VerIterator(void) { return **this; }
106 inline pkgCache
*Cache() const { return (**this).Cache(); };
107 inline unsigned long Index() const {return (**this).Index();};
108 // we have only valid iterators here
109 inline bool end() const { return false; };
111 inline pkgCache::Version
const * operator->() const {
115 inline int CompareVer(const pkgCache::VerIterator
&B
) const { return (**this).CompareVer(B
); };
116 inline const char *VerStr() const { return (**this).VerStr(); };
117 inline const char *Section() const { return (**this).Section(); };
118 inline const char *Arch() const { return (**this).Arch(); };
119 inline const char *Arch(bool const pseudo
) const { return (**this).Arch(pseudo
); };
120 inline pkgCache::PkgIterator
ParentPkg() const { return (**this).ParentPkg(); };
121 inline pkgCache::DescIterator
DescriptionList() const { return (**this).DescriptionList(); };
122 inline pkgCache::DescIterator
TranslatedDescription() const { return (**this).TranslatedDescription(); };
123 inline pkgCache::DepIterator
DependsList() const { return (**this).DependsList(); };
124 inline pkgCache::PrvIterator
ProvidesList() const { return (**this).ProvidesList(); };
125 inline pkgCache::VerFileIterator
FileList() const { return (**this).FileList(); };
126 inline bool Downloadable() const { return (**this).Downloadable(); };
127 inline const char *PriorityType() const { return (**this).PriorityType(); };
128 inline string
RelStr() const { return (**this).RelStr(); };
129 inline bool Automatic() const { return (**this).Automatic(); };
130 inline bool Pseudo() const { return (**this).Pseudo(); };
131 inline pkgCache::VerFileIterator
NewestFile() const { return (**this).NewestFile(); };
133 // 103. set::iterator is required to be modifiable, but this allows modification of keys
134 typedef typename
APT::VersionSet::const_iterator iterator
;