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_PUSH
229 return getPkg().Section();
230 APT_IGNORE_DEPRECATED_POP
232 inline bool Purge() const {return getPkg().Purge(); }
233 inline const char *Arch() const {return getPkg().Arch(); }
234 inline pkgCache::GrpIterator
Group() const { return getPkg().Group(); }
235 inline pkgCache::VerIterator
VersionList() const { return getPkg().VersionList(); }
236 inline pkgCache::VerIterator
CurrentVer() const { return getPkg().CurrentVer(); }
237 inline pkgCache::DepIterator
RevDependsList() const { return getPkg().RevDependsList(); }
238 inline pkgCache::PrvIterator
ProvidesList() const { return getPkg().ProvidesList(); }
239 inline pkgCache::PkgIterator::OkState
State() const { return getPkg().State(); }
240 inline const char *CandVersion() const { return getPkg().CandVersion(); }
241 inline const char *CurVersion() const { return getPkg().CurVersion(); }
242 inline pkgCache
*Cache() const { return getPkg().Cache(); }
243 inline unsigned long Index() const {return getPkg().Index();}
244 // we have only valid iterators here
245 inline bool end() const { return false; }
247 inline pkgCache::Package
const * operator->() const {return &*getPkg();}
251 virtual bool insert(pkgCache::PkgIterator
const &P
) = 0;
252 virtual bool empty() const = 0;
253 virtual void clear() = 0;
255 // FIXME: This is a bloody hack removed soon. Use CacheSetHelper::PkgSelector !
256 enum APT_DEPRECATED Constructor
{ UNKNOWN
= CacheSetHelper::UNKNOWN
,
257 REGEX
= CacheSetHelper::REGEX
,
258 TASK
= CacheSetHelper::TASK
,
259 FNMATCH
= CacheSetHelper::FNMATCH
};
260 APT_IGNORE_DEPRECATED_PUSH
261 void setConstructor(Constructor
const by
) { ConstructedBy
= (CacheSetHelper::PkgSelector
)by
; }
262 APT_IGNORE_DEPRECATED_POP
264 void setConstructor(CacheSetHelper::PkgSelector
const by
) { ConstructedBy
= by
; }
265 CacheSetHelper::PkgSelector
getConstructor() const { return ConstructedBy
; }
266 PackageContainerInterface() : ConstructedBy(CacheSetHelper::UNKNOWN
) {}
267 PackageContainerInterface(CacheSetHelper::PkgSelector
const by
) : ConstructedBy(by
) {}
269 APT_DEPRECATED
static bool FromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
270 return helper
.PackageFrom(CacheSetHelper::TASK
, pci
, Cache
, pattern
); }
271 APT_DEPRECATED
static bool FromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
272 return helper
.PackageFrom(CacheSetHelper::REGEX
, pci
, Cache
, pattern
); }
273 APT_DEPRECATED
static bool FromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
274 return helper
.PackageFrom(CacheSetHelper::FNMATCH
, pci
, Cache
, pattern
); }
275 APT_DEPRECATED
static bool FromGroup(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
276 return helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, pci
, Cache
, pattern
); }
277 APT_DEPRECATED
static bool FromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
278 return helper
.PackageFrom(CacheSetHelper::STRING
, pci
, Cache
, pattern
); }
279 APT_DEPRECATED
static bool FromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
280 return helper
.PackageFromCommandLine(pci
, Cache
, cmdline
); }
282 APT_DEPRECATED
typedef CacheSetHelper::PkgModifier Modifier
;
284 APT_IGNORE_DEPRECATED_PUSH
285 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
286 return helper
.PackageFromName(Cache
, pattern
); }
287 APT_DEPRECATED
static bool FromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
288 pkgCacheFile
&Cache
, const char * cmdline
,
289 std::list
<Modifier
> const &mods
, CacheSetHelper
&helper
) {
290 return helper
.PackageFromModifierCommandLine(modID
, pci
, Cache
, cmdline
, mods
); }
291 APT_IGNORE_DEPRECATED_POP
294 CacheSetHelper::PkgSelector ConstructedBy
;
297 template<class Container
> class PackageContainer
: public PackageContainerInterface
{/*{{{*/
298 /** \class APT::PackageContainer
300 Simple wrapper around a container class like std::set to provide a similar
301 interface to a set of packages as to the complete set of all packages in the
305 /** \brief smell like a pkgCache::PkgIterator */
306 class const_iterator
: public PackageContainerInterface::const_iterator
,/*{{{*/
307 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {
308 typename
Container::const_iterator _iter
;
310 const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
311 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
312 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
313 operator typename
Container::const_iterator(void) const { return _iter
; }
314 inline const_iterator
& operator++() { ++_iter
; return *this; }
315 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
316 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
317 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
318 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
320 class iterator
: public PackageContainerInterface::const_iterator
,
321 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
322 typename
Container::iterator _iter
;
324 iterator(typename
Container::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::iterator(void) const { return _iter
; }
328 operator typename PackageContainer
<Container
>::const_iterator() { return typename PackageContainer
<Container
>::const_iterator(_iter
); }
329 inline iterator
& operator++() { ++_iter
; return *this; }
330 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
331 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
332 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
333 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
334 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
335 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
339 bool insert(pkgCache::PkgIterator
const &P
) { if (P
.end() == true) return false; _cont
.insert(P
); return true; }
340 template<class Cont
> void insert(PackageContainer
<Cont
> const &pkgcont
) { _cont
.insert((typename
Cont::const_iterator
)pkgcont
.begin(), (typename
Cont::const_iterator
)pkgcont
.end()); }
341 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
343 bool empty() const { return _cont
.empty(); }
344 void clear() { return _cont
.clear(); }
345 //FIXME: on ABI break, replace the first with the second without bool
346 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
347 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
348 size_t erase(const pkgCache::PkgIterator x
) { return _cont
.erase(x
); }
349 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
350 size_t size() const { return _cont
.size(); }
352 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
353 const_iterator
end() const { return const_iterator(_cont
.end()); }
354 iterator
begin() { return iterator(_cont
.begin()); }
355 iterator
end() { return iterator(_cont
.end()); }
356 const_iterator
find(pkgCache::PkgIterator
const &P
) const { return const_iterator(_cont
.find(P
)); }
358 PackageContainer() : PackageContainerInterface() {}
359 PackageContainer(CacheSetHelper::PkgSelector
const &by
) : PackageContainerInterface(by
) {}
360 APT_IGNORE_DEPRECATED_PUSH
361 APT_DEPRECATED
PackageContainer(Constructor
const &by
) : PackageContainerInterface((CacheSetHelper::PkgSelector
)by
) {}
362 APT_IGNORE_DEPRECATED_POP
364 /** \brief sort all included versions with given comparer
366 Some containers are sorted by default, some are not and can't be,
367 but a few like std::vector can be sorted if need be, so this can be
368 specialized in later on. The default is that this will fail though.
369 Specifically, already sorted containers like std::set will return
370 false as well as there is no easy way to check that the given comparer
371 would sort in the same way the set is currently sorted
373 \return \b true if the set was sorted, \b false if not. */
374 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
376 /** \brief returns all packages in the cache who belong to the given task
378 A simple helper responsible for search for all members of a task
379 in the cache. Optional it prints a a notice about the
380 packages chosen cause of the given task.
381 \param Cache the packages are in
382 \param pattern name of the task
383 \param helper responsible for error and message handling */
384 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
385 PackageContainer
cont(CacheSetHelper::TASK
);
386 helper
.PackageFrom(CacheSetHelper::TASK
, &cont
, Cache
, pattern
);
389 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
) {
390 CacheSetHelper helper
;
391 return FromTask(Cache
, pattern
, helper
);
394 /** \brief returns all packages in the cache whose name matchs a given pattern
396 A simple helper responsible for executing a regular expression on all
397 package names in the cache. Optional it prints a a notice about the
398 packages chosen cause of the given package.
399 \param Cache the packages are in
400 \param pattern regular expression for package names
401 \param helper responsible for error and message handling */
402 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
403 PackageContainer
cont(CacheSetHelper::REGEX
);
404 helper
.PackageFrom(CacheSetHelper::REGEX
, &cont
, Cache
, pattern
);
408 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
) {
409 CacheSetHelper helper
;
410 return FromRegEx(Cache
, pattern
, helper
);
413 static PackageContainer
FromFnmatch(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
414 PackageContainer
cont(CacheSetHelper::FNMATCH
);
415 helper
.PackageFrom(CacheSetHelper::FNMATCH
, &cont
, Cache
, pattern
);
418 static PackageContainer
FromFnMatch(pkgCacheFile
&Cache
, std::string
const &pattern
) {
419 CacheSetHelper helper
;
420 return FromFnmatch(Cache
, pattern
, helper
);
423 APT_IGNORE_DEPRECATED_PUSH
424 /** \brief returns a package specified by a string
426 \param Cache the package is in
427 \param pattern String the package name should be extracted from
428 \param helper responsible for error and message handling */
429 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
430 return helper
.PackageFromName(Cache
, pattern
);
432 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
) {
433 CacheSetHelper helper
;
434 return FromName(Cache
, pattern
, helper
);
436 APT_IGNORE_DEPRECATED_POP
438 /** \brief returns all packages specified by a string
440 \param Cache the packages are in
441 \param pattern String the package name(s) should be extracted from
442 \param helper responsible for error and message handling */
443 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
444 PackageContainer cont
;
445 helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, &cont
, Cache
, pattern
);
448 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
) {
449 CacheSetHelper helper
;
450 return FromString(Cache
, pattern
, helper
);
453 /** \brief returns all packages specified on the commandline
455 Get all package names from the commandline and executes regex's if needed.
456 No special package command is supported, just plain names.
457 \param Cache the packages are in
458 \param cmdline Command line the package names should be extracted from
459 \param helper responsible for error and message handling */
460 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
461 PackageContainer cont
;
462 helper
.PackageFromCommandLine(&cont
, Cache
, cmdline
);
465 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
466 CacheSetHelper helper
;
467 return FromCommandLine(Cache
, cmdline
, helper
);
470 /** \brief group packages by a action modifiers
472 At some point it is needed to get from the same commandline
473 different package sets grouped by a modifier. Take
474 apt-get install apt awesome-
476 \param Cache the packages are in
477 \param cmdline Command line the package names should be extracted from
478 \param mods list of modifiers the method should accept
479 \param fallback the default modifier group for a package
480 \param helper responsible for error and message handling */
481 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
483 const char **cmdline
,
484 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
485 unsigned short const &fallback
,
486 CacheSetHelper
&helper
) {
487 std::map
<unsigned short, PackageContainer
> pkgsets
;
488 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
489 unsigned short modID
= fallback
;
490 PackageContainer pkgset
;
491 helper
.PackageFromModifierCommandLine(modID
, &pkgset
, Cache
, *I
, mods
);
492 pkgsets
[modID
].insert(pkgset
);
496 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
498 const char **cmdline
,
499 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
500 unsigned short const &fallback
) {
501 CacheSetHelper helper
;
502 return GroupedFromCommandLine(Cache
, cmdline
,
503 mods
, fallback
, helper
);
507 // specialisations for push_back containers: std::list & std::vector /*{{{*/
508 template<> template<class Cont
> void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
509 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
512 template<> template<class Cont
> void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
513 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
516 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
517 // specializations again and again - but we need to see them, so that library users can use them
518 template<> inline bool PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
524 template<> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
530 template<> inline void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
531 for (const_iterator p
= begin
; p
!= end
; ++p
)
534 template<> inline void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
535 for (const_iterator p
= begin
; p
!= end
; ++p
)
540 template<> template<class Compare
> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::sort(Compare Comp
) {
541 std::sort(_cont
.begin(), _cont
.end(), Comp
);
545 // class PackageUniverse - pkgCache as PackageContainerInterface /*{{{*/
546 /** \class PackageUniverse
548 Wraps around our usual pkgCache, so that it can be stuffed into methods
549 expecting a PackageContainer.
551 The wrapping is read-only in practice modeled by making erase and co
553 class APT_HIDDEN PackageUniverse
: public PackageContainerInterface
{
554 pkgCache
* const _cont
;
556 typedef pkgCache::PkgIterator iterator
;
557 typedef pkgCache::PkgIterator const_iterator
;
559 APT_PUBLIC
bool empty() const { return false; }
560 APT_PUBLIC
size_t size() const { return _cont
->Head().PackageCount
; }
562 APT_PUBLIC const_iterator
begin() const { return _cont
->PkgBegin(); }
563 APT_PUBLIC const_iterator
end() const { return _cont
->PkgEnd(); }
564 APT_PUBLIC iterator
begin() { return _cont
->PkgBegin(); }
565 APT_PUBLIC iterator
end() { return _cont
->PkgEnd(); }
567 APT_PUBLIC
PackageUniverse(pkgCache
* const Owner
) : _cont(Owner
) { }
570 bool insert(pkgCache::PkgIterator
const &) { return true; }
571 template<class Cont
> void insert(PackageContainer
<Cont
> const &) { }
572 void insert(const_iterator
, const_iterator
) { }
575 iterator
& erase(iterator
&iter
) { return iter
; }
576 size_t erase(const pkgCache::PkgIterator
) { return 0; }
577 void erase(iterator
, iterator
) { }
580 typedef PackageContainer
<std::set
<pkgCache::PkgIterator
> > PackageSet
;
581 typedef PackageContainer
<std::list
<pkgCache::PkgIterator
> > PackageList
;
582 typedef PackageContainer
<std::vector
<pkgCache::PkgIterator
> > PackageVector
;
584 class VersionContainerInterface
{ /*{{{*/
585 /** \class APT::VersionContainerInterface
587 Same as APT::PackageContainerInterface, just for Versions */
589 /** \brief smell like a pkgCache::VerIterator */
590 class const_iterator
{ /*{{{*/
592 virtual pkgCache::VerIterator
getVer() const = 0;
593 operator pkgCache::VerIterator(void) { return getVer(); }
595 inline pkgCache
*Cache() const { return getVer().Cache(); }
596 inline unsigned long Index() const {return getVer().Index();}
597 inline int CompareVer(const pkgCache::VerIterator
&B
) const { return getVer().CompareVer(B
); }
598 inline const char *VerStr() const { return getVer().VerStr(); }
599 inline const char *Section() const { return getVer().Section(); }
600 inline const char *Arch() const { return getVer().Arch(); }
601 inline pkgCache::PkgIterator
ParentPkg() const { return getVer().ParentPkg(); }
602 inline pkgCache::DescIterator
DescriptionList() const { return getVer().DescriptionList(); }
603 inline pkgCache::DescIterator
TranslatedDescription() const { return getVer().TranslatedDescription(); }
604 inline pkgCache::DepIterator
DependsList() const { return getVer().DependsList(); }
605 inline pkgCache::PrvIterator
ProvidesList() const { return getVer().ProvidesList(); }
606 inline pkgCache::VerFileIterator
FileList() const { return getVer().FileList(); }
607 inline bool Downloadable() const { return getVer().Downloadable(); }
608 inline const char *PriorityType() const { return getVer().PriorityType(); }
609 inline std::string
RelStr() const { return getVer().RelStr(); }
610 inline bool Automatic() const { return getVer().Automatic(); }
611 inline pkgCache::VerFileIterator
NewestFile() const { return getVer().NewestFile(); }
612 // we have only valid iterators here
613 inline bool end() const { return false; }
615 inline pkgCache::Version
const * operator->() const { return &*getVer(); }
619 virtual bool insert(pkgCache::VerIterator
const &V
) = 0;
620 virtual bool empty() const = 0;
621 virtual void clear() = 0;
623 /** \brief specifies which version(s) will be returned if non is given */
624 enum APT_DEPRECATED Version
{
625 ALL
= CacheSetHelper::ALL
,
626 CANDANDINST
= CacheSetHelper::CANDANDINST
,
627 CANDIDATE
= CacheSetHelper::CANDIDATE
,
628 INSTALLED
= CacheSetHelper::INSTALLED
,
629 CANDINST
= CacheSetHelper::CANDINST
,
630 INSTCAND
= CacheSetHelper::INSTCAND
,
631 NEWEST
= CacheSetHelper::NEWEST
635 unsigned short const ID
;
636 const char * const Alias
;
637 enum Position
{ NONE
, PREFIX
, POSTFIX
} const Pos
;
638 enum CacheSetHelper::VerSelector
const SelectVersion
;
639 Modifier (unsigned short const &id
, const char * const alias
, Position
const &pos
,
640 enum CacheSetHelper::VerSelector
const select
) : ID(id
), Alias(alias
), Pos(pos
),
641 SelectVersion(select
) {}
642 APT_IGNORE_DEPRECATED_PUSH
643 APT_DEPRECATED
Modifier(unsigned short const &id
, const char * const alias
, Position
const &pos
,
644 Version
const &select
) : ID(id
), Alias(alias
), Pos(pos
),
645 SelectVersion((CacheSetHelper::VerSelector
)select
) {}
646 APT_IGNORE_DEPRECATED_POP
649 static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
650 const char **cmdline
, CacheSetHelper::VerSelector
const fallback
,
651 CacheSetHelper
&helper
);
652 APT_IGNORE_DEPRECATED_PUSH
653 APT_DEPRECATED
static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
654 const char **cmdline
, Version
const &fallback
,
655 CacheSetHelper
&helper
) {
656 return FromCommandLine(vci
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
658 APT_IGNORE_DEPRECATED_POP
660 static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
661 std::string pkg
, CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
662 bool const onlyFromName
= false);
663 APT_IGNORE_DEPRECATED_PUSH
664 APT_DEPRECATED
static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
665 std::string pkg
, Version
const &fallback
, CacheSetHelper
&helper
,
666 bool const onlyFromName
= false) {
667 return FromString(vci
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
, onlyFromName
);
669 APT_IGNORE_DEPRECATED_POP
671 static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
672 pkgCache::PkgIterator
const &P
, CacheSetHelper::VerSelector
const fallback
,
673 CacheSetHelper
&helper
);
674 APT_IGNORE_DEPRECATED_PUSH
675 APT_DEPRECATED
static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
676 pkgCache::PkgIterator
const &P
, Version
const &fallback
,
677 CacheSetHelper
&helper
) {
678 return FromPackage(vci
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
680 APT_IGNORE_DEPRECATED_POP
682 static bool FromModifierCommandLine(unsigned short &modID
,
683 VersionContainerInterface
* const vci
,
684 pkgCacheFile
&Cache
, const char * cmdline
,
685 std::list
<Modifier
> const &mods
,
686 CacheSetHelper
&helper
);
689 static bool FromDependency(VersionContainerInterface
* const vci
,
691 pkgCache::DepIterator
const &D
,
692 CacheSetHelper::VerSelector
const selector
,
693 CacheSetHelper
&helper
);
694 APT_IGNORE_DEPRECATED_PUSH
695 APT_DEPRECATED
static bool FromDependency(VersionContainerInterface
* const vci
,
697 pkgCache::DepIterator
const &D
,
698 Version
const &selector
,
699 CacheSetHelper
&helper
) {
700 return FromDependency(vci
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
702 APT_IGNORE_DEPRECATED_POP
706 /** \brief returns the candidate version of the package
708 \param Cache to be used to query for information
709 \param Pkg we want the candidate version from this package
710 \param helper used in this container instance */
711 static pkgCache::VerIterator
getCandidateVer(pkgCacheFile
&Cache
,
712 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
714 /** \brief returns the installed version of the package
716 \param Cache to be used to query for information
717 \param Pkg we want the installed version from this package
718 \param helper used in this container instance */
719 static pkgCache::VerIterator
getInstalledVer(pkgCacheFile
&Cache
,
720 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
724 template<class Container
> class VersionContainer
: public VersionContainerInterface
{/*{{{*/
725 /** \class APT::VersionContainer
727 Simple wrapper around a container class like std::set to provide a similar
728 interface to a set of versions as to the complete set of all versions in the
732 /** \brief smell like a pkgCache::VerIterator */
733 class const_iterator
: public VersionContainerInterface::const_iterator
,
734 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {/*{{{*/
735 typename
Container::const_iterator _iter
;
737 const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
738 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
739 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
740 operator typename
Container::const_iterator(void) const { return _iter
; }
741 inline const_iterator
& operator++() { ++_iter
; return *this; }
742 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
743 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
744 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
745 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
747 class iterator
: public VersionContainerInterface::const_iterator
,
748 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
749 typename
Container::iterator _iter
;
751 iterator(typename
Container::iterator i
) : _iter(i
) {}
752 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
753 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
754 operator typename
Container::iterator(void) const { return _iter
; }
755 operator typename VersionContainer
<Container
>::const_iterator() { return typename VersionContainer
<Container
>::const_iterator(_iter
); }
756 inline iterator
& operator++() { ++_iter
; return *this; }
757 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
758 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
759 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
760 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
761 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
762 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
766 bool insert(pkgCache::VerIterator
const &V
) { if (V
.end() == true) return false; _cont
.insert(V
); return true; }
767 template<class Cont
> void insert(VersionContainer
<Cont
> const &vercont
) { _cont
.insert((typename
Cont::const_iterator
)vercont
.begin(), (typename
Cont::const_iterator
)vercont
.end()); }
768 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
769 bool empty() const { return _cont
.empty(); }
770 void clear() { return _cont
.clear(); }
771 //FIXME: on ABI break, replace the first with the second without bool
772 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
773 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
774 size_t erase(const pkgCache::VerIterator x
) { return _cont
.erase(x
); }
775 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
776 size_t size() const { return _cont
.size(); }
778 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
779 const_iterator
end() const { return const_iterator(_cont
.end()); }
780 iterator
begin() { return iterator(_cont
.begin()); }
781 iterator
end() { return iterator(_cont
.end()); }
782 const_iterator
find(pkgCache::VerIterator
const &V
) const { return const_iterator(_cont
.find(V
)); }
784 /** \brief sort all included versions with given comparer
786 Some containers are sorted by default, some are not and can't be,
787 but a few like std::vector can be sorted if need be, so this can be
788 specialized in later on. The default is that this will fail though.
789 Specifically, already sorted containers like std::set will return
790 false as well as there is no easy way to check that the given comparer
791 would sort in the same way the set is currently sorted
793 \return \b true if the set was sorted, \b false if not. */
794 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
796 /** \brief returns all versions specified on the commandline
798 Get all versions from the commandline, uses given default version if
799 non specifically requested and executes regex's if needed on names.
800 \param Cache the packages and versions are in
801 \param cmdline Command line the versions should be extracted from
802 \param fallback version specification
803 \param helper responsible for error and message handling */
804 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
805 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
806 VersionContainer vercon
;
807 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, fallback
, helper
);
810 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
811 CacheSetHelper::VerSelector
const fallback
) {
812 CacheSetHelper helper
;
813 return FromCommandLine(Cache
, cmdline
, fallback
, helper
);
815 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
816 return FromCommandLine(Cache
, cmdline
, CacheSetHelper::CANDINST
);
818 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
819 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
820 bool const /*onlyFromName = false*/) {
821 VersionContainer vercon
;
822 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, fallback
, helper
);
825 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
826 CacheSetHelper::VerSelector
const fallback
) {
827 CacheSetHelper helper
;
828 return FromString(Cache
, pkg
, fallback
, helper
);
830 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
) {
831 return FromString(Cache
, pkg
, CacheSetHelper::CANDINST
);
833 APT_IGNORE_DEPRECATED_PUSH
834 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
835 Version
const &fallback
, CacheSetHelper
&helper
) {
836 VersionContainer vercon
;
837 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
840 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
841 Version
const &fallback
) {
842 CacheSetHelper helper
;
843 return FromCommandLine(Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
845 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
846 Version
const &fallback
, CacheSetHelper
&helper
,
847 bool const /*onlyFromName = false*/) {
848 VersionContainer vercon
;
849 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
852 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
853 Version
const &fallback
) {
854 CacheSetHelper helper
;
855 return FromString(Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
857 APT_IGNORE_DEPRECATED_POP
859 /** \brief returns all versions specified for the package
861 \param Cache the package and versions are in
862 \param P the package in question
863 \param fallback the version(s) you want to get
864 \param helper the helper used for display and error handling */
865 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
866 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
867 VersionContainer vercon
;
868 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, fallback
, helper
);
871 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
872 CacheSetHelper::VerSelector
const fallback
) {
873 CacheSetHelper helper
;
874 return FromPackage(Cache
, P
, fallback
, helper
);
876 APT_IGNORE_DEPRECATED_PUSH
877 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
878 Version
const &fallback
, CacheSetHelper
&helper
) {
879 VersionContainer vercon
;
880 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
883 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
884 Version
const &fallback
) {
885 CacheSetHelper helper
;
886 return FromPackage(Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
888 APT_IGNORE_DEPRECATED_POP
889 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
) {
890 return FromPackage(Cache
, P
, CacheSetHelper::CANDIDATE
);
893 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
895 const char **cmdline
,
896 std::list
<Modifier
> const &mods
,
897 unsigned short const fallback
,
898 CacheSetHelper
&helper
) {
899 std::map
<unsigned short, VersionContainer
> versets
;
900 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
901 unsigned short modID
= fallback
;
902 VersionContainer verset
;
903 VersionContainerInterface::FromModifierCommandLine(modID
, &verset
, Cache
, *I
, mods
, helper
);
904 versets
[modID
].insert(verset
);
909 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
910 pkgCacheFile
&Cache
, const char **cmdline
,
911 std::list
<Modifier
> const &mods
,
912 unsigned short const fallback
) {
913 CacheSetHelper helper
;
914 return GroupedFromCommandLine(Cache
, cmdline
,
915 mods
, fallback
, helper
);
918 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
919 CacheSetHelper::VerSelector
const selector
, CacheSetHelper
&helper
) {
920 VersionContainer vercon
;
921 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, selector
, helper
);
924 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
925 CacheSetHelper::VerSelector
const selector
) {
926 CacheSetHelper helper
;
927 return FromPackage(Cache
, D
, selector
, helper
);
929 APT_IGNORE_DEPRECATED_PUSH
930 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
931 Version
const &selector
, CacheSetHelper
&helper
) {
932 VersionContainer vercon
;
933 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
936 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
937 Version
const &selector
) {
938 CacheSetHelper helper
;
939 return FromPackage(Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
941 APT_IGNORE_DEPRECATED_POP
942 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
) {
943 return FromPackage(Cache
, D
, CacheSetHelper::CANDIDATE
);
947 // specialisations for push_back containers: std::list & std::vector /*{{{*/
948 template<> template<class Cont
> void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
949 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
952 template<> template<class Cont
> void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
953 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
956 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
957 // specializations again and again - but we need to see them, so that library users can use them
958 template<> inline bool VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
964 template<> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
970 template<> inline void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
971 for (const_iterator v
= begin
; v
!= end
; ++v
)
974 template<> inline void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
975 for (const_iterator v
= begin
; v
!= end
; ++v
)
980 template<> template<class Compare
> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::sort(Compare Comp
) {
981 std::sort(_cont
.begin(), _cont
.end(), Comp
);
985 typedef VersionContainer
<std::set
<pkgCache::VerIterator
> > VersionSet
;
986 typedef VersionContainer
<std::list
<pkgCache::VerIterator
> > VersionList
;
987 typedef VersionContainer
<std::vector
<pkgCache::VerIterator
> > VersionVector
;