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>
26 #include <apt-pkg/macros.h>
28 #ifndef APT_8_CLEANER_HEADERS
29 #include <apt-pkg/cachefile.h>
31 #ifndef APT_10_CLEANER_HEADERS
39 class PackageContainerInterface
;
40 class VersionContainerInterface
;
42 class CacheSetHelper
{ /*{{{*/
43 /** \class APT::CacheSetHelper
44 Simple base class with a lot of virtual methods which can be overridden
45 to alter the behavior or the output of the CacheSets.
47 This helper is passed around by the static methods in the CacheSets and
48 used every time they hit an error condition or something could be
52 CacheSetHelper(bool const ShowError
= true,
53 GlobalError::MsgType ErrorType
= GlobalError::ERROR
) :
54 ShowError(ShowError
), ErrorType(ErrorType
) {}
55 virtual ~CacheSetHelper() {}
57 enum PkgSelector
{ UNKNOWN
, REGEX
, TASK
, FNMATCH
, PACKAGENAME
, STRING
};
59 virtual bool PackageFrom(enum PkgSelector
const select
, PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
61 virtual bool PackageFromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
);
64 enum Position
{ NONE
, PREFIX
, POSTFIX
};
66 const char * const Alias
;
68 PkgModifier (unsigned short const &id
, const char * const alias
, Position
const &pos
) : ID(id
), Alias(alias
), Pos(pos
) {}
70 virtual bool PackageFromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
71 pkgCacheFile
&Cache
, const char * cmdline
,
72 std::list
<PkgModifier
> const &mods
);
74 // use PackageFrom(PACKAGENAME, …) instead
75 APT_DEPRECATED
pkgCache::PkgIterator
PackageFromName(pkgCacheFile
&Cache
, std::string
const &pattern
);
77 /** \brief be notified about the package being selected via pattern
79 * Main use is probably to show a message to the user what happened
81 * \param pkg is the package which was selected
82 * \param select is the selection method which choose the package
83 * \param pattern is the string used by the selection method to pick the package
85 virtual void showPackageSelection(pkgCache::PkgIterator
const &pkg
, PkgSelector
const select
, std::string
const &pattern
);
86 // use the method above instead, react only on the type you need and let the base handle the rest if need be
87 // this allows use to add new selection methods without breaking the ABI constantly with new virtual methods
88 APT_DEPRECATED
virtual void showTaskSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
89 APT_DEPRECATED
virtual void showRegExSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
90 APT_DEPRECATED
virtual void showFnmatchSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
92 /** \brief be notified if a package can't be found via pattern
94 * Can be used to show a message as well as to try something else to make it match
96 * \param select is the method tried for selection
97 * \param pci is the container the package should be inserted in
98 * \param Cache is the package universe available
99 * \param pattern is the string not matching anything
101 virtual void canNotFindPackage(enum PkgSelector
const select
, PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
102 // same as above for showPackageSelection
103 APT_DEPRECATED
virtual void canNotFindTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
104 APT_DEPRECATED
virtual void canNotFindRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
105 APT_DEPRECATED
virtual void canNotFindFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
106 APT_DEPRECATED
virtual void canNotFindPackage(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &str
);
108 /** \brief specifies which version(s) we want to refer to */
110 /** by release string */
112 /** by version number string */
116 /** Candidate and installed version */
118 /** Candidate version */
120 /** Installed version */
122 /** Candidate or if non installed version */
124 /** Installed or if non candidate version */
126 /** Newest version */
130 /** \brief be notified about the version being selected via pattern
132 * Main use is probably to show a message to the user what happened
133 * Note that at the moment this method is only called for RELEASE
134 * and VERSION selections, not for the others.
136 * \param Pkg is the package which was selected for
137 * \param Ver is the version selected
138 * \param select is the selection method which choose the version
139 * \param pattern is the string used by the selection method to pick the version
141 virtual void showVersionSelection(pkgCache::PkgIterator
const &Pkg
, pkgCache::VerIterator
const &Ver
,
142 enum VerSelector
const select
, std::string
const &pattern
);
143 // renamed to have a similar interface to showPackageSelection
144 APT_DEPRECATED
virtual void showSelectedVersion(pkgCache::PkgIterator
const &Pkg
, pkgCache::VerIterator
const Ver
,
145 std::string
const &ver
, bool const verIsRel
);
147 /** \brief be notified if a version can't be found for a package
149 * Main use is probably to show a message to the user what happened
151 * \param select is the method tried for selection
152 * \param vci is the container the version should be inserted in
153 * \param Cache is the package universe available
154 * \param Pkg is the package we wanted a version from
156 virtual void canNotFindVersion(enum VerSelector
const select
, VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
157 // same as above for showPackageSelection
158 APT_DEPRECATED
virtual void canNotFindAllVer(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
159 APT_DEPRECATED
virtual void canNotFindInstCandVer(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
160 pkgCache::PkgIterator
const &Pkg
);
161 APT_DEPRECATED
virtual void canNotFindCandInstVer(VersionContainerInterface
* const vci
,
163 pkgCache::PkgIterator
const &Pkg
);
165 // the difference between canNotFind and canNotGet is that the later is more low-level
166 // and called from other places: In this case looking into the code is the only real answer…
167 virtual pkgCache::VerIterator
canNotGetVersion(enum VerSelector
const select
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
168 // same as above for showPackageSelection
169 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindNewestVer(pkgCacheFile
&Cache
,
170 pkgCache::PkgIterator
const &Pkg
);
171 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindCandidateVer(pkgCacheFile
&Cache
,
172 pkgCache::PkgIterator
const &Pkg
);
173 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindInstalledVer(pkgCacheFile
&Cache
,
174 pkgCache::PkgIterator
const &Pkg
);
176 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
);
178 bool showErrors() const { return ShowError
; }
179 bool showErrors(bool const newValue
) { if (ShowError
== newValue
) return ShowError
; else return ((ShowError
= newValue
) == false); }
180 GlobalError::MsgType
errorType() const { return ErrorType
; }
181 GlobalError::MsgType
errorType(GlobalError::MsgType
const &newValue
)
183 if (ErrorType
== newValue
) return ErrorType
;
185 GlobalError::MsgType
const &oldValue
= ErrorType
;
186 ErrorType
= newValue
;
194 GlobalError::MsgType ErrorType
;
196 pkgCache::VerIterator
canNotGetInstCandVer(pkgCacheFile
&Cache
,
197 pkgCache::PkgIterator
const &Pkg
);
198 pkgCache::VerIterator
canNotGetCandInstVer(pkgCacheFile
&Cache
,
199 pkgCache::PkgIterator
const &Pkg
);
201 bool PackageFromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
202 bool PackageFromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
203 bool PackageFromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
204 bool PackageFromPackageName(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
205 bool PackageFromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
208 class PackageContainerInterface
{ /*{{{*/
209 /** \class PackageContainerInterface
211 * Interface ensuring that all operations can be executed on the yet to
212 * define concrete PackageContainer - access to all methods is possible,
213 * but in general the wrappers provided by the PackageContainer template
216 * This class mostly protects use from the need to write all implementation
217 * of the methods working on containers in the template */
219 class const_iterator
{ /*{{{*/
221 virtual pkgCache::PkgIterator
getPkg() const = 0;
222 operator pkgCache::PkgIterator(void) const { return getPkg(); }
224 inline const char *Name() const {return getPkg().Name(); }
225 inline std::string
FullName(bool const Pretty
) const { return getPkg().FullName(Pretty
); }
226 inline std::string
FullName() const { return getPkg().FullName(); }
227 APT_DEPRECATED
inline const char *Section() const {
228 APT_IGNORE_DEPRECATED(return getPkg().Section();)
230 inline bool Purge() const {return getPkg().Purge(); }
231 inline const char *Arch() const {return getPkg().Arch(); }
232 inline pkgCache::GrpIterator
Group() const { return getPkg().Group(); }
233 inline pkgCache::VerIterator
VersionList() const { return getPkg().VersionList(); }
234 inline pkgCache::VerIterator
CurrentVer() const { return getPkg().CurrentVer(); }
235 inline pkgCache::DepIterator
RevDependsList() const { return getPkg().RevDependsList(); }
236 inline pkgCache::PrvIterator
ProvidesList() const { return getPkg().ProvidesList(); }
237 inline pkgCache::PkgIterator::OkState
State() const { return getPkg().State(); }
238 inline const char *CandVersion() const { return getPkg().CandVersion(); }
239 inline const char *CurVersion() const { return getPkg().CurVersion(); }
240 inline pkgCache
*Cache() const { return getPkg().Cache(); }
241 inline unsigned long Index() const {return getPkg().Index();}
242 // we have only valid iterators here
243 inline bool end() const { return false; }
245 inline pkgCache::Package
const * operator->() const {return &*getPkg();}
249 virtual bool insert(pkgCache::PkgIterator
const &P
) = 0;
250 virtual bool empty() const = 0;
251 virtual void clear() = 0;
253 // FIXME: This is a bloody hack removed soon. Use CacheSetHelper::PkgSelector !
254 enum APT_DEPRECATED Constructor
{ UNKNOWN
= CacheSetHelper::UNKNOWN
,
255 REGEX
= CacheSetHelper::REGEX
,
256 TASK
= CacheSetHelper::TASK
,
257 FNMATCH
= CacheSetHelper::FNMATCH
};
258 APT_IGNORE_DEPRECATED_PUSH
259 void setConstructor(Constructor
const by
) { ConstructedBy
= (CacheSetHelper::PkgSelector
)by
; }
260 APT_IGNORE_DEPRECATED_POP
262 void setConstructor(CacheSetHelper::PkgSelector
const by
) { ConstructedBy
= by
; }
263 CacheSetHelper::PkgSelector
getConstructor() const { return ConstructedBy
; }
264 PackageContainerInterface() : ConstructedBy(CacheSetHelper::UNKNOWN
) {}
265 PackageContainerInterface(CacheSetHelper::PkgSelector
const by
) : ConstructedBy(by
) {}
267 APT_DEPRECATED
static bool FromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
268 return helper
.PackageFrom(CacheSetHelper::TASK
, pci
, Cache
, pattern
); }
269 APT_DEPRECATED
static bool FromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
270 return helper
.PackageFrom(CacheSetHelper::REGEX
, pci
, Cache
, pattern
); }
271 APT_DEPRECATED
static bool FromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
272 return helper
.PackageFrom(CacheSetHelper::FNMATCH
, pci
, Cache
, pattern
); }
273 APT_DEPRECATED
static bool FromGroup(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
274 return helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, pci
, Cache
, pattern
); }
275 APT_DEPRECATED
static bool FromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
276 return helper
.PackageFrom(CacheSetHelper::STRING
, pci
, Cache
, pattern
); }
277 APT_DEPRECATED
static bool FromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
278 return helper
.PackageFromCommandLine(pci
, Cache
, cmdline
); }
280 APT_DEPRECATED
typedef CacheSetHelper::PkgModifier Modifier
;
282 APT_IGNORE_DEPRECATED_PUSH
283 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
284 return helper
.PackageFromName(Cache
, pattern
); }
285 APT_DEPRECATED
static bool FromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
286 pkgCacheFile
&Cache
, const char * cmdline
,
287 std::list
<Modifier
> const &mods
, CacheSetHelper
&helper
) {
288 return helper
.PackageFromModifierCommandLine(modID
, pci
, Cache
, cmdline
, mods
); }
289 APT_IGNORE_DEPRECATED_POP
292 CacheSetHelper::PkgSelector ConstructedBy
;
295 template<class Container
> class PackageContainer
: public PackageContainerInterface
{/*{{{*/
296 /** \class APT::PackageContainer
298 Simple wrapper around a container class like std::set to provide a similar
299 interface to a set of packages as to the complete set of all packages in the
303 /** \brief smell like a pkgCache::PkgIterator */
304 class const_iterator
: public PackageContainerInterface::const_iterator
,/*{{{*/
305 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {
306 typename
Container::const_iterator _iter
;
308 const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
309 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
310 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
311 operator typename
Container::const_iterator(void) const { return _iter
; }
312 inline const_iterator
& operator++() { ++_iter
; return *this; }
313 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
314 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
315 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
316 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
318 class iterator
: public PackageContainerInterface::const_iterator
,
319 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
320 typename
Container::iterator _iter
;
322 iterator(typename
Container::iterator i
) : _iter(i
) {}
323 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
324 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
325 operator typename
Container::iterator(void) const { return _iter
; }
326 operator typename PackageContainer
<Container
>::const_iterator() { return typename PackageContainer
<Container
>::const_iterator(_iter
); }
327 inline iterator
& operator++() { ++_iter
; return *this; }
328 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
329 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
330 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
331 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
332 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
333 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
337 bool insert(pkgCache::PkgIterator
const &P
) { if (P
.end() == true) return false; _cont
.insert(P
); return true; }
338 template<class Cont
> void insert(PackageContainer
<Cont
> const &pkgcont
) { _cont
.insert((typename
Cont::const_iterator
)pkgcont
.begin(), (typename
Cont::const_iterator
)pkgcont
.end()); }
339 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
341 bool empty() const { return _cont
.empty(); }
342 void clear() { return _cont
.clear(); }
343 //FIXME: on ABI break, replace the first with the second without bool
344 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
345 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
346 size_t erase(const pkgCache::PkgIterator x
) { return _cont
.erase(x
); }
347 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
348 size_t size() const { return _cont
.size(); }
350 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
351 const_iterator
end() const { return const_iterator(_cont
.end()); }
352 iterator
begin() { return iterator(_cont
.begin()); }
353 iterator
end() { return iterator(_cont
.end()); }
354 const_iterator
find(pkgCache::PkgIterator
const &P
) const { return const_iterator(_cont
.find(P
)); }
356 PackageContainer() : PackageContainerInterface() {}
357 PackageContainer(CacheSetHelper::PkgSelector
const &by
) : PackageContainerInterface(by
) {}
358 APT_IGNORE_DEPRECATED_PUSH
359 APT_DEPRECATED
PackageContainer(Constructor
const &by
) : PackageContainerInterface((CacheSetHelper::PkgSelector
)by
) {}
360 APT_IGNORE_DEPRECATED_POP
362 /** \brief sort all included versions with given comparer
364 Some containers are sorted by default, some are not and can't be,
365 but a few like std::vector can be sorted if need be, so this can be
366 specialized in later on. The default is that this will fail though.
367 Specifically, already sorted containers like std::set will return
368 false as well as there is no easy way to check that the given comparer
369 would sort in the same way the set is currently sorted
371 \return \b true if the set was sorted, \b false if not. */
372 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
374 /** \brief returns all packages in the cache who belong to the given task
376 A simple helper responsible for search for all members of a task
377 in the cache. Optional it prints a a notice about the
378 packages chosen cause of the given task.
379 \param Cache the packages are in
380 \param pattern name of the task
381 \param helper responsible for error and message handling */
382 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
383 PackageContainer
cont(CacheSetHelper::TASK
);
384 helper
.PackageFrom(CacheSetHelper::TASK
, &cont
, Cache
, pattern
);
387 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
) {
388 CacheSetHelper helper
;
389 return FromTask(Cache
, pattern
, helper
);
392 /** \brief returns all packages in the cache whose name matchs a given pattern
394 A simple helper responsible for executing a regular expression on all
395 package names in the cache. Optional it prints a a notice about the
396 packages chosen cause of the given package.
397 \param Cache the packages are in
398 \param pattern regular expression for package names
399 \param helper responsible for error and message handling */
400 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
401 PackageContainer
cont(CacheSetHelper::REGEX
);
402 helper
.PackageFrom(CacheSetHelper::REGEX
, &cont
, Cache
, pattern
);
406 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
) {
407 CacheSetHelper helper
;
408 return FromRegEx(Cache
, pattern
, helper
);
411 static PackageContainer
FromFnmatch(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
412 PackageContainer
cont(CacheSetHelper::FNMATCH
);
413 helper
.PackageFrom(CacheSetHelper::FNMATCH
, &cont
, Cache
, pattern
);
416 static PackageContainer
FromFnMatch(pkgCacheFile
&Cache
, std::string
const &pattern
) {
417 CacheSetHelper helper
;
418 return FromFnmatch(Cache
, pattern
, helper
);
421 APT_IGNORE_DEPRECATED_PUSH
422 /** \brief returns a package specified by a string
424 \param Cache the package is in
425 \param pattern String the package name should be extracted from
426 \param helper responsible for error and message handling */
427 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
428 return helper
.PackageFromName(Cache
, pattern
);
430 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
) {
431 CacheSetHelper helper
;
432 return FromName(Cache
, pattern
, helper
);
434 APT_IGNORE_DEPRECATED_POP
436 /** \brief returns all packages specified by a string
438 \param Cache the packages are in
439 \param pattern String the package name(s) should be extracted from
440 \param helper responsible for error and message handling */
441 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
442 PackageContainer cont
;
443 helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, &cont
, Cache
, pattern
);
446 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
) {
447 CacheSetHelper helper
;
448 return FromString(Cache
, pattern
, helper
);
451 /** \brief returns all packages specified on the commandline
453 Get all package names from the commandline and executes regex's if needed.
454 No special package command is supported, just plain names.
455 \param Cache the packages are in
456 \param cmdline Command line the package names should be extracted from
457 \param helper responsible for error and message handling */
458 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
459 PackageContainer cont
;
460 helper
.PackageFromCommandLine(&cont
, Cache
, cmdline
);
463 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
464 CacheSetHelper helper
;
465 return FromCommandLine(Cache
, cmdline
, helper
);
468 /** \brief group packages by a action modifiers
470 At some point it is needed to get from the same commandline
471 different package sets grouped by a modifier. Take
472 apt-get install apt awesome-
474 \param Cache the packages are in
475 \param cmdline Command line the package names should be extracted from
476 \param mods list of modifiers the method should accept
477 \param fallback the default modifier group for a package
478 \param helper responsible for error and message handling */
479 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
481 const char **cmdline
,
482 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
483 unsigned short const &fallback
,
484 CacheSetHelper
&helper
) {
485 std::map
<unsigned short, PackageContainer
> pkgsets
;
486 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
487 unsigned short modID
= fallback
;
488 PackageContainer pkgset
;
489 helper
.PackageFromModifierCommandLine(modID
, &pkgset
, Cache
, *I
, mods
);
490 pkgsets
[modID
].insert(pkgset
);
494 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
496 const char **cmdline
,
497 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
498 unsigned short const &fallback
) {
499 CacheSetHelper helper
;
500 return GroupedFromCommandLine(Cache
, cmdline
,
501 mods
, fallback
, helper
);
505 // specialisations for push_back containers: std::list & std::vector /*{{{*/
506 template<> template<class Cont
> void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
507 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
510 template<> template<class Cont
> void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
511 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
514 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
515 // specializations again and again - but we need to see them, so that library users can use them
516 template<> inline bool PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
522 template<> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
528 template<> inline void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
529 for (const_iterator p
= begin
; p
!= end
; ++p
)
532 template<> inline void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
533 for (const_iterator p
= begin
; p
!= end
; ++p
)
538 template<> template<class Compare
> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::sort(Compare Comp
) {
539 std::sort(_cont
.begin(), _cont
.end(), Comp
);
543 // class PackageUniverse - pkgCache as PackageContainerInterface /*{{{*/
544 /** \class PackageUniverse
546 Wraps around our usual pkgCache, so that it can be stuffed into methods
547 expecting a PackageContainer.
549 The wrapping is read-only in practice modeled by making erase and co
551 class APT_HIDDEN PackageUniverse
: public PackageContainerInterface
{
552 pkgCache
* const _cont
;
554 typedef pkgCache::PkgIterator iterator
;
555 typedef pkgCache::PkgIterator const_iterator
;
557 APT_PUBLIC
bool empty() const { return false; }
558 APT_PUBLIC
size_t size() const { return _cont
->Head().PackageCount
; }
560 APT_PUBLIC const_iterator
begin() const { return _cont
->PkgBegin(); }
561 APT_PUBLIC const_iterator
end() const { return _cont
->PkgEnd(); }
562 APT_PUBLIC iterator
begin() { return _cont
->PkgBegin(); }
563 APT_PUBLIC iterator
end() { return _cont
->PkgEnd(); }
565 APT_PUBLIC
PackageUniverse(pkgCache
* const Owner
) : _cont(Owner
) { }
568 bool insert(pkgCache::PkgIterator
const &) { return true; }
569 template<class Cont
> void insert(PackageContainer
<Cont
> const &) { }
570 void insert(const_iterator
, const_iterator
) { }
573 iterator
& erase(iterator
&iter
) { return iter
; }
574 size_t erase(const pkgCache::PkgIterator
) { return 0; }
575 void erase(iterator
, iterator
) { }
578 typedef PackageContainer
<std::set
<pkgCache::PkgIterator
> > PackageSet
;
579 typedef PackageContainer
<std::list
<pkgCache::PkgIterator
> > PackageList
;
580 typedef PackageContainer
<std::vector
<pkgCache::PkgIterator
> > PackageVector
;
582 class VersionContainerInterface
{ /*{{{*/
583 /** \class APT::VersionContainerInterface
585 Same as APT::PackageContainerInterface, just for Versions */
587 /** \brief smell like a pkgCache::VerIterator */
588 class const_iterator
{ /*{{{*/
590 virtual pkgCache::VerIterator
getVer() const = 0;
591 operator pkgCache::VerIterator(void) { return getVer(); }
593 inline pkgCache
*Cache() const { return getVer().Cache(); }
594 inline unsigned long Index() const {return getVer().Index();}
595 inline int CompareVer(const pkgCache::VerIterator
&B
) const { return getVer().CompareVer(B
); }
596 inline const char *VerStr() const { return getVer().VerStr(); }
597 inline const char *Section() const { return getVer().Section(); }
598 inline const char *Arch() const { return getVer().Arch(); }
599 inline pkgCache::PkgIterator
ParentPkg() const { return getVer().ParentPkg(); }
600 inline pkgCache::DescIterator
DescriptionList() const { return getVer().DescriptionList(); }
601 inline pkgCache::DescIterator
TranslatedDescription() const { return getVer().TranslatedDescription(); }
602 inline pkgCache::DepIterator
DependsList() const { return getVer().DependsList(); }
603 inline pkgCache::PrvIterator
ProvidesList() const { return getVer().ProvidesList(); }
604 inline pkgCache::VerFileIterator
FileList() const { return getVer().FileList(); }
605 inline bool Downloadable() const { return getVer().Downloadable(); }
606 inline const char *PriorityType() const { return getVer().PriorityType(); }
607 inline std::string
RelStr() const { return getVer().RelStr(); }
608 inline bool Automatic() const { return getVer().Automatic(); }
609 inline pkgCache::VerFileIterator
NewestFile() const { return getVer().NewestFile(); }
610 // we have only valid iterators here
611 inline bool end() const { return false; }
613 inline pkgCache::Version
const * operator->() const { return &*getVer(); }
617 virtual bool insert(pkgCache::VerIterator
const &V
) = 0;
618 virtual bool empty() const = 0;
619 virtual void clear() = 0;
621 /** \brief specifies which version(s) will be returned if non is given */
622 enum APT_DEPRECATED Version
{
623 ALL
= CacheSetHelper::ALL
,
624 CANDANDINST
= CacheSetHelper::CANDANDINST
,
625 CANDIDATE
= CacheSetHelper::CANDIDATE
,
626 INSTALLED
= CacheSetHelper::INSTALLED
,
627 CANDINST
= CacheSetHelper::CANDINST
,
628 INSTCAND
= CacheSetHelper::INSTCAND
,
629 NEWEST
= CacheSetHelper::NEWEST
633 unsigned short const ID
;
634 const char * const Alias
;
635 enum Position
{ NONE
, PREFIX
, POSTFIX
} const Pos
;
636 enum CacheSetHelper::VerSelector
const SelectVersion
;
637 Modifier (unsigned short const &id
, const char * const alias
, Position
const &pos
,
638 enum CacheSetHelper::VerSelector
const select
) : ID(id
), Alias(alias
), Pos(pos
),
639 SelectVersion(select
) {}
640 APT_IGNORE_DEPRECATED_PUSH
641 APT_DEPRECATED
Modifier(unsigned short const &id
, const char * const alias
, Position
const &pos
,
642 Version
const &select
) : ID(id
), Alias(alias
), Pos(pos
),
643 SelectVersion((CacheSetHelper::VerSelector
)select
) {}
644 APT_IGNORE_DEPRECATED_POP
647 static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
648 const char **cmdline
, CacheSetHelper::VerSelector
const fallback
,
649 CacheSetHelper
&helper
);
650 APT_IGNORE_DEPRECATED_PUSH
651 APT_DEPRECATED
static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
652 const char **cmdline
, Version
const &fallback
,
653 CacheSetHelper
&helper
) {
654 return FromCommandLine(vci
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
656 APT_IGNORE_DEPRECATED_POP
658 static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
659 std::string pkg
, CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
660 bool const onlyFromName
= false);
661 APT_IGNORE_DEPRECATED_PUSH
662 APT_DEPRECATED
static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
663 std::string pkg
, Version
const &fallback
, CacheSetHelper
&helper
,
664 bool const onlyFromName
= false) {
665 return FromString(vci
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
, onlyFromName
);
667 APT_IGNORE_DEPRECATED_POP
669 static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
670 pkgCache::PkgIterator
const &P
, CacheSetHelper::VerSelector
const fallback
,
671 CacheSetHelper
&helper
);
672 APT_IGNORE_DEPRECATED_PUSH
673 APT_DEPRECATED
static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
674 pkgCache::PkgIterator
const &P
, Version
const &fallback
,
675 CacheSetHelper
&helper
) {
676 return FromPackage(vci
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
678 APT_IGNORE_DEPRECATED_POP
680 static bool FromModifierCommandLine(unsigned short &modID
,
681 VersionContainerInterface
* const vci
,
682 pkgCacheFile
&Cache
, const char * cmdline
,
683 std::list
<Modifier
> const &mods
,
684 CacheSetHelper
&helper
);
687 static bool FromDependency(VersionContainerInterface
* const vci
,
689 pkgCache::DepIterator
const &D
,
690 CacheSetHelper::VerSelector
const selector
,
691 CacheSetHelper
&helper
);
692 APT_IGNORE_DEPRECATED_PUSH
693 APT_DEPRECATED
static bool FromDependency(VersionContainerInterface
* const vci
,
695 pkgCache::DepIterator
const &D
,
696 Version
const &selector
,
697 CacheSetHelper
&helper
) {
698 return FromDependency(vci
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
700 APT_IGNORE_DEPRECATED_POP
704 /** \brief returns the candidate version of the package
706 \param Cache to be used to query for information
707 \param Pkg we want the candidate version from this package
708 \param helper used in this container instance */
709 static pkgCache::VerIterator
getCandidateVer(pkgCacheFile
&Cache
,
710 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
712 /** \brief returns the installed version of the package
714 \param Cache to be used to query for information
715 \param Pkg we want the installed version from this package
716 \param helper used in this container instance */
717 static pkgCache::VerIterator
getInstalledVer(pkgCacheFile
&Cache
,
718 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
722 template<class Container
> class VersionContainer
: public VersionContainerInterface
{/*{{{*/
723 /** \class APT::VersionContainer
725 Simple wrapper around a container class like std::set to provide a similar
726 interface to a set of versions as to the complete set of all versions in the
730 /** \brief smell like a pkgCache::VerIterator */
731 class const_iterator
: public VersionContainerInterface::const_iterator
,
732 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {/*{{{*/
733 typename
Container::const_iterator _iter
;
735 const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
736 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
737 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
738 operator typename
Container::const_iterator(void) const { return _iter
; }
739 inline const_iterator
& operator++() { ++_iter
; return *this; }
740 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
741 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
742 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
743 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
745 class iterator
: public VersionContainerInterface::const_iterator
,
746 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
747 typename
Container::iterator _iter
;
749 iterator(typename
Container::iterator i
) : _iter(i
) {}
750 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
751 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
752 operator typename
Container::iterator(void) const { return _iter
; }
753 operator typename VersionContainer
<Container
>::const_iterator() { return typename VersionContainer
<Container
>::const_iterator(_iter
); }
754 inline iterator
& operator++() { ++_iter
; return *this; }
755 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
756 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
757 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
758 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
759 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
760 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
764 bool insert(pkgCache::VerIterator
const &V
) { if (V
.end() == true) return false; _cont
.insert(V
); return true; }
765 template<class Cont
> void insert(VersionContainer
<Cont
> const &vercont
) { _cont
.insert((typename
Cont::const_iterator
)vercont
.begin(), (typename
Cont::const_iterator
)vercont
.end()); }
766 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
767 bool empty() const { return _cont
.empty(); }
768 void clear() { return _cont
.clear(); }
769 //FIXME: on ABI break, replace the first with the second without bool
770 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
771 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
772 size_t erase(const pkgCache::VerIterator x
) { return _cont
.erase(x
); }
773 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
774 size_t size() const { return _cont
.size(); }
776 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
777 const_iterator
end() const { return const_iterator(_cont
.end()); }
778 iterator
begin() { return iterator(_cont
.begin()); }
779 iterator
end() { return iterator(_cont
.end()); }
780 const_iterator
find(pkgCache::VerIterator
const &V
) const { return const_iterator(_cont
.find(V
)); }
782 /** \brief sort all included versions with given comparer
784 Some containers are sorted by default, some are not and can't be,
785 but a few like std::vector can be sorted if need be, so this can be
786 specialized in later on. The default is that this will fail though.
787 Specifically, already sorted containers like std::set will return
788 false as well as there is no easy way to check that the given comparer
789 would sort in the same way the set is currently sorted
791 \return \b true if the set was sorted, \b false if not. */
792 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
794 /** \brief returns all versions specified on the commandline
796 Get all versions from the commandline, uses given default version if
797 non specifically requested and executes regex's if needed on names.
798 \param Cache the packages and versions are in
799 \param cmdline Command line the versions should be extracted from
800 \param fallback version specification
801 \param helper responsible for error and message handling */
802 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
803 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
804 VersionContainer vercon
;
805 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, fallback
, helper
);
808 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
809 CacheSetHelper::VerSelector
const fallback
) {
810 CacheSetHelper helper
;
811 return FromCommandLine(Cache
, cmdline
, fallback
, helper
);
813 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
814 return FromCommandLine(Cache
, cmdline
, CacheSetHelper::CANDINST
);
816 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
817 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
818 bool const /*onlyFromName = false*/) {
819 VersionContainer vercon
;
820 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, fallback
, helper
);
823 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
824 CacheSetHelper::VerSelector
const fallback
) {
825 CacheSetHelper helper
;
826 return FromString(Cache
, pkg
, fallback
, helper
);
828 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
) {
829 return FromString(Cache
, pkg
, CacheSetHelper::CANDINST
);
831 APT_IGNORE_DEPRECATED_PUSH
832 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
833 Version
const &fallback
, CacheSetHelper
&helper
) {
834 VersionContainer vercon
;
835 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
838 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
839 Version
const &fallback
) {
840 CacheSetHelper helper
;
841 return FromCommandLine(Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
843 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
844 Version
const &fallback
, CacheSetHelper
&helper
,
845 bool const /*onlyFromName = false*/) {
846 VersionContainer vercon
;
847 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
850 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
851 Version
const &fallback
) {
852 CacheSetHelper helper
;
853 return FromString(Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
855 APT_IGNORE_DEPRECATED_POP
857 /** \brief returns all versions specified for the package
859 \param Cache the package and versions are in
860 \param P the package in question
861 \param fallback the version(s) you want to get
862 \param helper the helper used for display and error handling */
863 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
864 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
865 VersionContainer vercon
;
866 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, fallback
, helper
);
869 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
870 CacheSetHelper::VerSelector
const fallback
) {
871 CacheSetHelper helper
;
872 return FromPackage(Cache
, P
, fallback
, helper
);
874 APT_IGNORE_DEPRECATED_PUSH
875 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
876 Version
const &fallback
, CacheSetHelper
&helper
) {
877 VersionContainer vercon
;
878 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
881 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
882 Version
const &fallback
) {
883 CacheSetHelper helper
;
884 return FromPackage(Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
886 APT_IGNORE_DEPRECATED_POP
887 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
) {
888 return FromPackage(Cache
, P
, CacheSetHelper::CANDIDATE
);
891 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
893 const char **cmdline
,
894 std::list
<Modifier
> const &mods
,
895 unsigned short const fallback
,
896 CacheSetHelper
&helper
) {
897 std::map
<unsigned short, VersionContainer
> versets
;
898 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
899 unsigned short modID
= fallback
;
900 VersionContainer verset
;
901 VersionContainerInterface::FromModifierCommandLine(modID
, &verset
, Cache
, *I
, mods
, helper
);
902 versets
[modID
].insert(verset
);
907 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
908 pkgCacheFile
&Cache
, const char **cmdline
,
909 std::list
<Modifier
> const &mods
,
910 unsigned short const fallback
) {
911 CacheSetHelper helper
;
912 return GroupedFromCommandLine(Cache
, cmdline
,
913 mods
, fallback
, helper
);
916 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
917 CacheSetHelper::VerSelector
const selector
, CacheSetHelper
&helper
) {
918 VersionContainer vercon
;
919 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, selector
, helper
);
922 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
923 CacheSetHelper::VerSelector
const selector
) {
924 CacheSetHelper helper
;
925 return FromPackage(Cache
, D
, selector
, helper
);
927 APT_IGNORE_DEPRECATED_PUSH
928 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
929 Version
const &selector
, CacheSetHelper
&helper
) {
930 VersionContainer vercon
;
931 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
934 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
935 Version
const &selector
) {
936 CacheSetHelper helper
;
937 return FromPackage(Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
939 APT_IGNORE_DEPRECATED_POP
940 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
) {
941 return FromPackage(Cache
, D
, CacheSetHelper::CANDIDATE
);
945 // specialisations for push_back containers: std::list & std::vector /*{{{*/
946 template<> template<class Cont
> void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
947 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
950 template<> template<class Cont
> void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
951 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
954 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
955 // specializations again and again - but we need to see them, so that library users can use them
956 template<> inline bool VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
962 template<> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
968 template<> inline void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
969 for (const_iterator v
= begin
; v
!= end
; ++v
)
972 template<> inline void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
973 for (const_iterator v
= begin
; v
!= end
; ++v
)
978 template<> template<class Compare
> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::sort(Compare Comp
) {
979 std::sort(_cont
.begin(), _cont
.end(), Comp
);
983 typedef VersionContainer
<std::set
<pkgCache::VerIterator
> > VersionSet
;
984 typedef VersionContainer
<std::list
<pkgCache::VerIterator
> > VersionList
;
985 typedef VersionContainer
<std::vector
<pkgCache::VerIterator
> > VersionVector
;