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 /*{{{*/
23 #include <apt-pkg/error.h>
24 #include <apt-pkg/pkgcache.h>
25 #include <apt-pkg/cacheiterators.h>
27 #ifndef APT_8_CLEANER_HEADERS
28 #include <apt-pkg/cachefile.h>
30 #ifndef APT_10_CLEANER_HEADERS
38 class PackageContainerInterface
;
39 class VersionContainerInterface
;
41 class CacheSetHelper
{ /*{{{*/
42 /** \class APT::CacheSetHelper
43 Simple base class with a lot of virtual methods which can be overridden
44 to alter the behavior or the output of the CacheSets.
46 This helper is passed around by the static methods in the CacheSets and
47 used every time they hit an error condition or something could be
51 CacheSetHelper(bool const ShowError
= true,
52 GlobalError::MsgType ErrorType
= GlobalError::ERROR
) :
53 ShowError(ShowError
), ErrorType(ErrorType
) {}
54 virtual ~CacheSetHelper() {}
56 enum PkgSelector
{ UNKNOWN
, REGEX
, TASK
, FNMATCH
, PACKAGENAME
, STRING
};
58 virtual bool PackageFrom(enum PkgSelector
const select
, PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
60 virtual bool PackageFromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
);
63 enum Position
{ NONE
, PREFIX
, POSTFIX
};
65 const char * const Alias
;
67 PkgModifier (unsigned short const &id
, const char * const alias
, Position
const &pos
) : ID(id
), Alias(alias
), Pos(pos
) {}
69 virtual bool PackageFromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
70 pkgCacheFile
&Cache
, const char * cmdline
,
71 std::list
<PkgModifier
> const &mods
);
73 // use PackageFrom(PACKAGENAME, …) instead
74 APT_DEPRECATED
pkgCache::PkgIterator
PackageFromName(pkgCacheFile
&Cache
, std::string
const &pattern
);
76 /** \brief be notified about the package being selected via pattern
78 * Main use is probably to show a message to the user what happened
80 * \param pkg is the package which was selected
81 * \param select is the selection method which choose the package
82 * \param pattern is the string used by the selection method to pick the package
84 virtual void showPackageSelection(pkgCache::PkgIterator
const &pkg
, PkgSelector
const select
, std::string
const &pattern
);
85 // use the method above instead, react only on the type you need and let the base handle the rest if need be
86 // this allows use to add new selection methods without breaking the ABI constantly with new virtual methods
87 APT_DEPRECATED
virtual void showTaskSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
88 APT_DEPRECATED
virtual void showRegExSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
89 APT_DEPRECATED
virtual void showFnmatchSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
91 /** \brief be notified if a package can't be found via pattern
93 * Can be used to show a message as well as to try something else to make it match
95 * \param select is the method tried for selection
96 * \param pci is the container the package should be inserted in
97 * \param Cache is the package universe available
98 * \param pattern is the string not matching anything
100 virtual void canNotFindPackage(enum PkgSelector
const select
, PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
101 // same as above for showPackageSelection
102 APT_DEPRECATED
virtual void canNotFindTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
103 APT_DEPRECATED
virtual void canNotFindRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
104 APT_DEPRECATED
virtual void canNotFindFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
105 APT_DEPRECATED
virtual void canNotFindPackage(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &str
);
107 /** \brief specifies which version(s) we want to refer to */
109 /** by release string */
111 /** by version number string */
115 /** Candidate and installed version */
117 /** Candidate version */
119 /** Installed version */
121 /** Candidate or if non installed version */
123 /** Installed or if non candidate version */
125 /** Newest version */
129 /** \brief be notified about the version being selected via pattern
131 * Main use is probably to show a message to the user what happened
132 * Note that at the moment this method is only called for RELEASE
133 * and VERSION selections, not for the others.
135 * \param Pkg is the package which was selected for
136 * \param Ver is the version selected
137 * \param select is the selection method which choose the version
138 * \param pattern is the string used by the selection method to pick the version
140 virtual void showVersionSelection(pkgCache::PkgIterator
const &Pkg
, pkgCache::VerIterator
const &Ver
,
141 enum VerSelector
const select
, std::string
const &pattern
);
142 // renamed to have a similar interface to showPackageSelection
143 APT_DEPRECATED
virtual void showSelectedVersion(pkgCache::PkgIterator
const &Pkg
, pkgCache::VerIterator
const Ver
,
144 std::string
const &ver
, bool const verIsRel
);
146 /** \brief be notified if a version can't be found for a package
148 * Main use is probably to show a message to the user what happened
150 * \param select is the method tried for selection
151 * \param vci is the container the version should be inserted in
152 * \param Cache is the package universe available
153 * \param Pkg is the package we wanted a version from
155 virtual void canNotFindVersion(enum VerSelector
const select
, VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
156 // same as above for showPackageSelection
157 APT_DEPRECATED
virtual void canNotFindAllVer(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
158 APT_DEPRECATED
virtual void canNotFindInstCandVer(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
159 pkgCache::PkgIterator
const &Pkg
);
160 APT_DEPRECATED
virtual void canNotFindCandInstVer(VersionContainerInterface
* const vci
,
162 pkgCache::PkgIterator
const &Pkg
);
164 // the difference between canNotFind and canNotGet is that the later is more low-level
165 // and called from other places: In this case looking into the code is the only real answer…
166 virtual pkgCache::VerIterator
canNotGetVersion(enum VerSelector
const select
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
167 // same as above for showPackageSelection
168 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindNewestVer(pkgCacheFile
&Cache
,
169 pkgCache::PkgIterator
const &Pkg
);
170 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindCandidateVer(pkgCacheFile
&Cache
,
171 pkgCache::PkgIterator
const &Pkg
);
172 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindInstalledVer(pkgCacheFile
&Cache
,
173 pkgCache::PkgIterator
const &Pkg
);
175 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
);
177 bool showErrors() const { return ShowError
; }
178 bool showErrors(bool const newValue
) { if (ShowError
== newValue
) return ShowError
; else return ((ShowError
= newValue
) == false); }
179 GlobalError::MsgType
errorType() const { return ErrorType
; }
180 GlobalError::MsgType
errorType(GlobalError::MsgType
const &newValue
)
182 if (ErrorType
== newValue
) return ErrorType
;
184 GlobalError::MsgType
const &oldValue
= ErrorType
;
185 ErrorType
= newValue
;
193 GlobalError::MsgType ErrorType
;
195 pkgCache::VerIterator
canNotGetInstCandVer(pkgCacheFile
&Cache
,
196 pkgCache::PkgIterator
const &Pkg
);
197 pkgCache::VerIterator
canNotGetCandInstVer(pkgCacheFile
&Cache
,
198 pkgCache::PkgIterator
const &Pkg
);
200 bool PackageFromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
201 bool PackageFromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
202 bool PackageFromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
203 bool PackageFromPackageName(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
204 bool PackageFromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
207 class PackageContainerInterface
{ /*{{{*/
208 /** \class PackageContainerInterface
210 * Interface ensuring that all operations can be executed on the yet to
211 * define concrete PackageContainer - access to all methods is possible,
212 * but in general the wrappers provided by the PackageContainer template
215 * This class mostly protects use from the need to write all implementation
216 * of the methods working on containers in the template */
218 class const_iterator
{ /*{{{*/
220 virtual pkgCache::PkgIterator
getPkg() const = 0;
221 operator pkgCache::PkgIterator(void) const { return getPkg(); }
223 inline const char *Name() const {return getPkg().Name(); }
224 inline std::string
FullName(bool const Pretty
) const { return getPkg().FullName(Pretty
); }
225 inline std::string
FullName() const { return getPkg().FullName(); }
226 APT_DEPRECATED
inline const char *Section() const {
228 #pragma GCC diagnostic push
229 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
231 return getPkg().Section();
233 #pragma GCC diagnostic pop
236 inline bool Purge() const {return getPkg().Purge(); }
237 inline const char *Arch() const {return getPkg().Arch(); }
238 inline pkgCache::GrpIterator
Group() const { return getPkg().Group(); }
239 inline pkgCache::VerIterator
VersionList() const { return getPkg().VersionList(); }
240 inline pkgCache::VerIterator
CurrentVer() const { return getPkg().CurrentVer(); }
241 inline pkgCache::DepIterator
RevDependsList() const { return getPkg().RevDependsList(); }
242 inline pkgCache::PrvIterator
ProvidesList() const { return getPkg().ProvidesList(); }
243 inline pkgCache::PkgIterator::OkState
State() const { return getPkg().State(); }
244 inline const char *CandVersion() const { return getPkg().CandVersion(); }
245 inline const char *CurVersion() const { return getPkg().CurVersion(); }
246 inline pkgCache
*Cache() const { return getPkg().Cache(); }
247 inline unsigned long Index() const {return getPkg().Index();}
248 // we have only valid iterators here
249 inline bool end() const { return false; }
251 inline pkgCache::Package
const * operator->() const {return &*getPkg();}
255 virtual bool insert(pkgCache::PkgIterator
const &P
) = 0;
256 virtual bool empty() const = 0;
257 virtual void clear() = 0;
259 // FIXME: This is a bloody hack removed soon. Use CacheSetHelper::PkgSelector !
260 enum APT_DEPRECATED Constructor
{ UNKNOWN
= CacheSetHelper::UNKNOWN
,
261 REGEX
= CacheSetHelper::REGEX
,
262 TASK
= CacheSetHelper::TASK
,
263 FNMATCH
= CacheSetHelper::FNMATCH
};
265 #pragma GCC diagnostic push
266 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
268 void setConstructor(Constructor
const by
) { ConstructedBy
= (CacheSetHelper::PkgSelector
)by
; }
270 #pragma GCC diagnostic pop
273 void setConstructor(CacheSetHelper::PkgSelector
const by
) { ConstructedBy
= by
; }
274 CacheSetHelper::PkgSelector
getConstructor() const { return ConstructedBy
; }
275 PackageContainerInterface() : ConstructedBy(CacheSetHelper::UNKNOWN
) {}
276 PackageContainerInterface(CacheSetHelper::PkgSelector
const by
) : ConstructedBy(by
) {}
278 APT_DEPRECATED
static bool FromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
279 return helper
.PackageFrom(CacheSetHelper::TASK
, pci
, Cache
, pattern
); }
280 APT_DEPRECATED
static bool FromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
281 return helper
.PackageFrom(CacheSetHelper::REGEX
, pci
, Cache
, pattern
); }
282 APT_DEPRECATED
static bool FromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
283 return helper
.PackageFrom(CacheSetHelper::FNMATCH
, pci
, Cache
, pattern
); }
284 APT_DEPRECATED
static bool FromGroup(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
285 return helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, pci
, Cache
, pattern
); }
286 APT_DEPRECATED
static bool FromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
287 return helper
.PackageFrom(CacheSetHelper::STRING
, pci
, Cache
, pattern
); }
288 APT_DEPRECATED
static bool FromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
289 return helper
.PackageFromCommandLine(pci
, Cache
, cmdline
); }
291 APT_DEPRECATED
typedef CacheSetHelper::PkgModifier Modifier
;
294 #pragma GCC diagnostic push
295 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
297 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
298 return helper
.PackageFromName(Cache
, pattern
); }
299 APT_DEPRECATED
static bool FromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
300 pkgCacheFile
&Cache
, const char * cmdline
,
301 std::list
<Modifier
> const &mods
, CacheSetHelper
&helper
) {
302 return helper
.PackageFromModifierCommandLine(modID
, pci
, Cache
, cmdline
, mods
); }
304 #pragma GCC diagnostic pop
308 CacheSetHelper::PkgSelector ConstructedBy
;
311 template<class Container
> class PackageContainer
: public PackageContainerInterface
{/*{{{*/
312 /** \class APT::PackageContainer
314 Simple wrapper around a container class like std::set to provide a similar
315 interface to a set of packages as to the complete set of all packages in the
319 /** \brief smell like a pkgCache::PkgIterator */
320 class const_iterator
: public PackageContainerInterface::const_iterator
,/*{{{*/
321 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {
322 typename
Container::const_iterator _iter
;
324 const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
325 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
326 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
327 operator typename
Container::const_iterator(void) const { return _iter
; }
328 inline const_iterator
& operator++() { ++_iter
; return *this; }
329 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
330 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
331 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
332 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
334 class iterator
: public PackageContainerInterface::const_iterator
,
335 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
336 typename
Container::iterator _iter
;
338 iterator(typename
Container::iterator i
) : _iter(i
) {}
339 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
340 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
341 operator typename
Container::iterator(void) const { return _iter
; }
342 operator typename PackageContainer
<Container
>::const_iterator() { return typename PackageContainer
<Container
>::const_iterator(_iter
); }
343 inline iterator
& operator++() { ++_iter
; return *this; }
344 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
345 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
346 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
347 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
348 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
349 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
353 bool insert(pkgCache::PkgIterator
const &P
) { if (P
.end() == true) return false; _cont
.insert(P
); return true; }
354 template<class Cont
> void insert(PackageContainer
<Cont
> const &pkgcont
) { _cont
.insert((typename
Cont::const_iterator
)pkgcont
.begin(), (typename
Cont::const_iterator
)pkgcont
.end()); }
355 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
357 bool empty() const { return _cont
.empty(); }
358 void clear() { return _cont
.clear(); }
359 //FIXME: on ABI break, replace the first with the second without bool
360 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
361 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
362 size_t erase(const pkgCache::PkgIterator x
) { return _cont
.erase(x
); }
363 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
364 size_t size() const { return _cont
.size(); }
366 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
367 const_iterator
end() const { return const_iterator(_cont
.end()); }
368 iterator
begin() { return iterator(_cont
.begin()); }
369 iterator
end() { return iterator(_cont
.end()); }
370 const_iterator
find(pkgCache::PkgIterator
const &P
) const { return const_iterator(_cont
.find(P
)); }
372 PackageContainer() : PackageContainerInterface() {}
373 PackageContainer(CacheSetHelper::PkgSelector
const &by
) : PackageContainerInterface(by
) {}
375 #pragma GCC diagnostic push
376 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
378 APT_DEPRECATED
PackageContainer(Constructor
const &by
) : PackageContainerInterface((CacheSetHelper::PkgSelector
)by
) {}
380 #pragma GCC diagnostic pop
383 /** \brief sort all included versions with given comparer
385 Some containers are sorted by default, some are not and can't be,
386 but a few like std::vector can be sorted if need be, so this can be
387 specialized in later on. The default is that this will fail though.
388 Specifically, already sorted containers like std::set will return
389 false as well as there is no easy way to check that the given comparer
390 would sort in the same way the set is currently sorted
392 \return \b true if the set was sorted, \b false if not. */
393 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
395 /** \brief returns all packages in the cache who belong to the given task
397 A simple helper responsible for search for all members of a task
398 in the cache. Optional it prints a a notice about the
399 packages chosen cause of the given task.
400 \param Cache the packages are in
401 \param pattern name of the task
402 \param helper responsible for error and message handling */
403 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
404 PackageContainer
cont(CacheSetHelper::TASK
);
405 helper
.PackageFrom(CacheSetHelper::TASK
, &cont
, Cache
, pattern
);
408 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
) {
409 CacheSetHelper helper
;
410 return FromTask(Cache
, pattern
, helper
);
413 /** \brief returns all packages in the cache whose name matchs a given pattern
415 A simple helper responsible for executing a regular expression on all
416 package names in the cache. Optional it prints a a notice about the
417 packages chosen cause of the given package.
418 \param Cache the packages are in
419 \param pattern regular expression for package names
420 \param helper responsible for error and message handling */
421 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
422 PackageContainer
cont(CacheSetHelper::REGEX
);
423 helper
.PackageFrom(CacheSetHelper::REGEX
, &cont
, Cache
, pattern
);
427 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
) {
428 CacheSetHelper helper
;
429 return FromRegEx(Cache
, pattern
, helper
);
432 static PackageContainer
FromFnmatch(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
433 PackageContainer
cont(CacheSetHelper::FNMATCH
);
434 helper
.PackageFrom(CacheSetHelper::FNMATCH
, &cont
, Cache
, pattern
);
437 static PackageContainer
FromFnMatch(pkgCacheFile
&Cache
, std::string
const &pattern
) {
438 CacheSetHelper helper
;
439 return FromFnmatch(Cache
, pattern
, helper
);
443 #pragma GCC diagnostic push
444 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
446 /** \brief returns a package specified by a string
448 \param Cache the package is in
449 \param pattern String the package name should be extracted from
450 \param helper responsible for error and message handling */
451 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
452 return helper
.PackageFromName(Cache
, pattern
);
454 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
) {
455 CacheSetHelper helper
;
456 return FromName(Cache
, pattern
, helper
);
459 #pragma GCC diagnostic pop
462 /** \brief returns all packages specified by a string
464 \param Cache the packages are in
465 \param pattern String the package name(s) should be extracted from
466 \param helper responsible for error and message handling */
467 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
468 PackageContainer cont
;
469 helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, &cont
, Cache
, pattern
);
472 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
) {
473 CacheSetHelper helper
;
474 return FromString(Cache
, pattern
, helper
);
477 /** \brief returns all packages specified on the commandline
479 Get all package names from the commandline and executes regex's if needed.
480 No special package command is supported, just plain names.
481 \param Cache the packages are in
482 \param cmdline Command line the package names should be extracted from
483 \param helper responsible for error and message handling */
484 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
485 PackageContainer cont
;
486 helper
.PackageFromCommandLine(&cont
, Cache
, cmdline
);
489 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
490 CacheSetHelper helper
;
491 return FromCommandLine(Cache
, cmdline
, helper
);
494 /** \brief group packages by a action modifiers
496 At some point it is needed to get from the same commandline
497 different package sets grouped by a modifier. Take
498 apt-get install apt awesome-
500 \param Cache the packages are in
501 \param cmdline Command line the package names should be extracted from
502 \param mods list of modifiers the method should accept
503 \param fallback the default modifier group for a package
504 \param helper responsible for error and message handling */
505 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
507 const char **cmdline
,
508 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
509 unsigned short const &fallback
,
510 CacheSetHelper
&helper
) {
511 std::map
<unsigned short, PackageContainer
> pkgsets
;
512 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
513 unsigned short modID
= fallback
;
514 PackageContainer pkgset
;
515 helper
.PackageFromModifierCommandLine(modID
, &pkgset
, Cache
, *I
, mods
);
516 pkgsets
[modID
].insert(pkgset
);
520 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
522 const char **cmdline
,
523 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
524 unsigned short const &fallback
) {
525 CacheSetHelper helper
;
526 return GroupedFromCommandLine(Cache
, cmdline
,
527 mods
, fallback
, helper
);
531 // specialisations for push_back containers: std::list & std::vector /*{{{*/
532 template<> template<class Cont
> void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
533 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
536 template<> template<class Cont
> void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
537 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
540 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
541 // specializations again and again - but we need to see them, so that library users can use them
542 template<> inline bool PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
548 template<> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
554 template<> inline void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
555 for (const_iterator p
= begin
; p
!= end
; ++p
)
558 template<> inline void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
559 for (const_iterator p
= begin
; p
!= end
; ++p
)
564 template<> template<class Compare
> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::sort(Compare Comp
) {
565 std::sort(_cont
.begin(), _cont
.end(), Comp
);
569 // class PackageUniverse - pkgCache as PackageContainerInterface /*{{{*/
570 /** \class PackageUniverse
572 Wraps around our usual pkgCache, so that it can be stuffed into methods
573 expecting a PackageContainer.
575 The wrapping is read-only in practice modeled by making erase and co
577 class PackageUniverse
: public PackageContainerInterface
{
578 pkgCache
* const _cont
;
580 typedef pkgCache::PkgIterator iterator
;
581 typedef pkgCache::PkgIterator const_iterator
;
583 bool empty() const { return false; }
584 size_t size() const { return _cont
->Head().PackageCount
; }
586 const_iterator
begin() const { return _cont
->PkgBegin(); }
587 const_iterator
end() const { return _cont
->PkgEnd(); }
588 iterator
begin() { return _cont
->PkgBegin(); }
589 iterator
end() { return _cont
->PkgEnd(); }
591 PackageUniverse(pkgCache
* const Owner
) : _cont(Owner
) { }
594 bool insert(pkgCache::PkgIterator
const &) { return true; }
595 template<class Cont
> void insert(PackageContainer
<Cont
> const &) { }
596 void insert(const_iterator
, const_iterator
) { }
599 iterator
& erase(iterator
&iter
) { return iter
; }
600 size_t erase(const pkgCache::PkgIterator
) { return 0; }
601 void erase(iterator
, iterator
) { }
604 typedef PackageContainer
<std::set
<pkgCache::PkgIterator
> > PackageSet
;
605 typedef PackageContainer
<std::list
<pkgCache::PkgIterator
> > PackageList
;
606 typedef PackageContainer
<std::vector
<pkgCache::PkgIterator
> > PackageVector
;
608 class VersionContainerInterface
{ /*{{{*/
609 /** \class APT::VersionContainerInterface
611 Same as APT::PackageContainerInterface, just for Versions */
613 /** \brief smell like a pkgCache::VerIterator */
614 class const_iterator
{ /*{{{*/
616 virtual pkgCache::VerIterator
getVer() const = 0;
617 operator pkgCache::VerIterator(void) { return getVer(); }
619 inline pkgCache
*Cache() const { return getVer().Cache(); }
620 inline unsigned long Index() const {return getVer().Index();}
621 inline int CompareVer(const pkgCache::VerIterator
&B
) const { return getVer().CompareVer(B
); }
622 inline const char *VerStr() const { return getVer().VerStr(); }
623 inline const char *Section() const { return getVer().Section(); }
624 inline const char *Arch() const { return getVer().Arch(); }
625 inline pkgCache::PkgIterator
ParentPkg() const { return getVer().ParentPkg(); }
626 inline pkgCache::DescIterator
DescriptionList() const { return getVer().DescriptionList(); }
627 inline pkgCache::DescIterator
TranslatedDescription() const { return getVer().TranslatedDescription(); }
628 inline pkgCache::DepIterator
DependsList() const { return getVer().DependsList(); }
629 inline pkgCache::PrvIterator
ProvidesList() const { return getVer().ProvidesList(); }
630 inline pkgCache::VerFileIterator
FileList() const { return getVer().FileList(); }
631 inline bool Downloadable() const { return getVer().Downloadable(); }
632 inline const char *PriorityType() const { return getVer().PriorityType(); }
633 inline std::string
RelStr() const { return getVer().RelStr(); }
634 inline bool Automatic() const { return getVer().Automatic(); }
635 inline pkgCache::VerFileIterator
NewestFile() const { return getVer().NewestFile(); }
636 // we have only valid iterators here
637 inline bool end() const { return false; }
639 inline pkgCache::Version
const * operator->() const { return &*getVer(); }
643 virtual bool insert(pkgCache::VerIterator
const &V
) = 0;
644 virtual bool empty() const = 0;
645 virtual void clear() = 0;
647 /** \brief specifies which version(s) will be returned if non is given */
648 enum APT_DEPRECATED Version
{
649 ALL
= CacheSetHelper::ALL
,
650 CANDANDINST
= CacheSetHelper::CANDANDINST
,
651 CANDIDATE
= CacheSetHelper::CANDIDATE
,
652 INSTALLED
= CacheSetHelper::INSTALLED
,
653 CANDINST
= CacheSetHelper::CANDINST
,
654 INSTCAND
= CacheSetHelper::INSTCAND
,
655 NEWEST
= CacheSetHelper::NEWEST
659 unsigned short const ID
;
660 const char * const Alias
;
661 enum Position
{ NONE
, PREFIX
, POSTFIX
} const Pos
;
662 enum CacheSetHelper::VerSelector
const SelectVersion
;
663 Modifier (unsigned short const &id
, const char * const alias
, Position
const &pos
,
664 enum CacheSetHelper::VerSelector
const select
) : ID(id
), Alias(alias
), Pos(pos
),
665 SelectVersion(select
) {}
667 #pragma GCC diagnostic push
668 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
670 APT_DEPRECATED
Modifier(unsigned short const &id
, const char * const alias
, Position
const &pos
,
671 Version
const &select
) : ID(id
), Alias(alias
), Pos(pos
),
672 SelectVersion((CacheSetHelper::VerSelector
)select
) {}
674 #pragma GCC diagnostic pop
678 static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
679 const char **cmdline
, CacheSetHelper::VerSelector
const fallback
,
680 CacheSetHelper
&helper
);
682 #pragma GCC diagnostic push
683 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
685 APT_DEPRECATED
static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
686 const char **cmdline
, Version
const &fallback
,
687 CacheSetHelper
&helper
) {
688 return FromCommandLine(vci
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
691 #pragma GCC diagnostic pop
694 static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
695 std::string pkg
, CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
696 bool const onlyFromName
= false);
698 #pragma GCC diagnostic push
699 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
701 APT_DEPRECATED
static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
702 std::string pkg
, Version
const &fallback
, CacheSetHelper
&helper
,
703 bool const onlyFromName
= false) {
704 return FromString(vci
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
, onlyFromName
);
707 #pragma GCC diagnostic pop
710 static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
711 pkgCache::PkgIterator
const &P
, CacheSetHelper::VerSelector
const fallback
,
712 CacheSetHelper
&helper
);
714 #pragma GCC diagnostic push
715 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
717 APT_DEPRECATED
static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
718 pkgCache::PkgIterator
const &P
, Version
const &fallback
,
719 CacheSetHelper
&helper
) {
720 return FromPackage(vci
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
723 #pragma GCC diagnostic pop
726 static bool FromModifierCommandLine(unsigned short &modID
,
727 VersionContainerInterface
* const vci
,
728 pkgCacheFile
&Cache
, const char * cmdline
,
729 std::list
<Modifier
> const &mods
,
730 CacheSetHelper
&helper
);
733 static bool FromDependency(VersionContainerInterface
* const vci
,
735 pkgCache::DepIterator
const &D
,
736 CacheSetHelper::VerSelector
const selector
,
737 CacheSetHelper
&helper
);
739 #pragma GCC diagnostic push
740 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
742 APT_DEPRECATED
static bool FromDependency(VersionContainerInterface
* const vci
,
744 pkgCache::DepIterator
const &D
,
745 Version
const &selector
,
746 CacheSetHelper
&helper
) {
747 return FromDependency(vci
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
750 #pragma GCC diagnostic pop
755 /** \brief returns the candidate version of the package
757 \param Cache to be used to query for information
758 \param Pkg we want the candidate version from this package
759 \param helper used in this container instance */
760 static pkgCache::VerIterator
getCandidateVer(pkgCacheFile
&Cache
,
761 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
763 /** \brief returns the installed version of the package
765 \param Cache to be used to query for information
766 \param Pkg we want the installed version from this package
767 \param helper used in this container instance */
768 static pkgCache::VerIterator
getInstalledVer(pkgCacheFile
&Cache
,
769 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
773 template<class Container
> class VersionContainer
: public VersionContainerInterface
{/*{{{*/
774 /** \class APT::VersionContainer
776 Simple wrapper around a container class like std::set to provide a similar
777 interface to a set of versions as to the complete set of all versions in the
781 /** \brief smell like a pkgCache::VerIterator */
782 class const_iterator
: public VersionContainerInterface::const_iterator
,
783 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {/*{{{*/
784 typename
Container::const_iterator _iter
;
786 const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
787 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
788 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
789 operator typename
Container::const_iterator(void) const { return _iter
; }
790 inline const_iterator
& operator++() { ++_iter
; return *this; }
791 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
792 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
793 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
794 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
796 class iterator
: public VersionContainerInterface::const_iterator
,
797 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
798 typename
Container::iterator _iter
;
800 iterator(typename
Container::iterator i
) : _iter(i
) {}
801 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
802 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
803 operator typename
Container::iterator(void) const { return _iter
; }
804 operator typename VersionContainer
<Container
>::const_iterator() { return typename VersionContainer
<Container
>::const_iterator(_iter
); }
805 inline iterator
& operator++() { ++_iter
; return *this; }
806 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
807 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
808 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
809 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
810 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
811 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
815 bool insert(pkgCache::VerIterator
const &V
) { if (V
.end() == true) return false; _cont
.insert(V
); return true; }
816 template<class Cont
> void insert(VersionContainer
<Cont
> const &vercont
) { _cont
.insert((typename
Cont::const_iterator
)vercont
.begin(), (typename
Cont::const_iterator
)vercont
.end()); }
817 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
818 bool empty() const { return _cont
.empty(); }
819 void clear() { return _cont
.clear(); }
820 //FIXME: on ABI break, replace the first with the second without bool
821 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
822 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
823 size_t erase(const pkgCache::VerIterator x
) { return _cont
.erase(x
); }
824 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
825 size_t size() const { return _cont
.size(); }
827 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
828 const_iterator
end() const { return const_iterator(_cont
.end()); }
829 iterator
begin() { return iterator(_cont
.begin()); }
830 iterator
end() { return iterator(_cont
.end()); }
831 const_iterator
find(pkgCache::VerIterator
const &V
) const { return const_iterator(_cont
.find(V
)); }
833 /** \brief sort all included versions with given comparer
835 Some containers are sorted by default, some are not and can't be,
836 but a few like std::vector can be sorted if need be, so this can be
837 specialized in later on. The default is that this will fail though.
838 Specifically, already sorted containers like std::set will return
839 false as well as there is no easy way to check that the given comparer
840 would sort in the same way the set is currently sorted
842 \return \b true if the set was sorted, \b false if not. */
843 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
845 /** \brief returns all versions specified on the commandline
847 Get all versions from the commandline, uses given default version if
848 non specifically requested and executes regex's if needed on names.
849 \param Cache the packages and versions are in
850 \param cmdline Command line the versions should be extracted from
851 \param fallback version specification
852 \param helper responsible for error and message handling */
853 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
854 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
855 VersionContainer vercon
;
856 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, fallback
, helper
);
859 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
860 CacheSetHelper::VerSelector
const fallback
) {
861 CacheSetHelper helper
;
862 return FromCommandLine(Cache
, cmdline
, fallback
, helper
);
864 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
865 return FromCommandLine(Cache
, cmdline
, CacheSetHelper::CANDINST
);
867 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
868 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
869 bool const /*onlyFromName = false*/) {
870 VersionContainer vercon
;
871 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, fallback
, helper
);
874 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
875 CacheSetHelper::VerSelector
const fallback
) {
876 CacheSetHelper helper
;
877 return FromString(Cache
, pkg
, fallback
, helper
);
879 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
) {
880 return FromString(Cache
, pkg
, CacheSetHelper::CANDINST
);
883 #pragma GCC diagnostic push
884 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
886 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
887 Version
const &fallback
, CacheSetHelper
&helper
) {
888 VersionContainer vercon
;
889 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
892 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
893 Version
const &fallback
) {
894 CacheSetHelper helper
;
895 return FromCommandLine(Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
897 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
898 Version
const &fallback
, CacheSetHelper
&helper
,
899 bool const /*onlyFromName = false*/) {
900 VersionContainer vercon
;
901 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
904 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
905 Version
const &fallback
) {
906 CacheSetHelper helper
;
907 return FromString(Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
910 #pragma GCC diagnostic pop
913 /** \brief returns all versions specified for the package
915 \param Cache the package and versions are in
916 \param P the package in question
917 \param fallback the version(s) you want to get
918 \param helper the helper used for display and error handling */
919 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
920 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
921 VersionContainer vercon
;
922 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, fallback
, helper
);
925 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
926 CacheSetHelper::VerSelector
const fallback
) {
927 CacheSetHelper helper
;
928 return FromPackage(Cache
, P
, fallback
, helper
);
931 #pragma GCC diagnostic push
932 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
934 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
935 Version
const &fallback
, CacheSetHelper
&helper
) {
936 VersionContainer vercon
;
937 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
940 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
941 Version
const &fallback
) {
942 CacheSetHelper helper
;
943 return FromPackage(Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
946 #pragma GCC diagnostic pop
948 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
) {
949 return FromPackage(Cache
, P
, CacheSetHelper::CANDIDATE
);
952 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
954 const char **cmdline
,
955 std::list
<Modifier
> const &mods
,
956 unsigned short const fallback
,
957 CacheSetHelper
&helper
) {
958 std::map
<unsigned short, VersionContainer
> versets
;
959 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
960 unsigned short modID
= fallback
;
961 VersionContainer verset
;
962 VersionContainerInterface::FromModifierCommandLine(modID
, &verset
, Cache
, *I
, mods
, helper
);
963 versets
[modID
].insert(verset
);
968 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
969 pkgCacheFile
&Cache
, const char **cmdline
,
970 std::list
<Modifier
> const &mods
,
971 unsigned short const fallback
) {
972 CacheSetHelper helper
;
973 return GroupedFromCommandLine(Cache
, cmdline
,
974 mods
, fallback
, helper
);
977 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
978 CacheSetHelper::VerSelector
const selector
, CacheSetHelper
&helper
) {
979 VersionContainer vercon
;
980 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, selector
, helper
);
983 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
984 CacheSetHelper::VerSelector
const selector
) {
985 CacheSetHelper helper
;
986 return FromPackage(Cache
, D
, selector
, helper
);
989 #pragma GCC diagnostic push
990 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
992 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
993 Version
const &selector
, CacheSetHelper
&helper
) {
994 VersionContainer vercon
;
995 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
998 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
999 Version
const &selector
) {
1000 CacheSetHelper helper
;
1001 return FromPackage(Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
1004 #pragma GCC diagnostic pop
1006 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
) {
1007 return FromPackage(Cache
, D
, CacheSetHelper::CANDIDATE
);
1011 // specialisations for push_back containers: std::list & std::vector /*{{{*/
1012 template<> template<class Cont
> void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
1013 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
1014 _cont
.push_back(*v
);
1016 template<> template<class Cont
> void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
1017 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
1018 _cont
.push_back(*v
);
1020 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
1021 // specializations again and again - but we need to see them, so that library users can use them
1022 template<> inline bool VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
1023 if (V
.end() == true)
1028 template<> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
1029 if (V
.end() == true)
1034 template<> inline void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
1035 for (const_iterator v
= begin
; v
!= end
; ++v
)
1036 _cont
.push_back(*v
);
1038 template<> inline void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
1039 for (const_iterator v
= begin
; v
!= end
; ++v
)
1040 _cont
.push_back(*v
);
1044 template<> template<class Compare
> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::sort(Compare Comp
) {
1045 std::sort(_cont
.begin(), _cont
.end(), Comp
);
1049 typedef VersionContainer
<std::set
<pkgCache::VerIterator
> > VersionSet
;
1050 typedef VersionContainer
<std::list
<pkgCache::VerIterator
> > VersionList
;
1051 typedef VersionContainer
<std::vector
<pkgCache::VerIterator
> > VersionVector
;