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 virtual ~CacheSetHelper();
56 enum PkgSelector
{ UNKNOWN
, REGEX
, TASK
, FNMATCH
, PACKAGENAME
, STRING
};
58 virtual bool PackageFrom(enum PkgSelector
const select
, PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
60 virtual bool PackageFromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
);
63 enum Position
{ NONE
, PREFIX
, POSTFIX
};
65 const char * const Alias
;
67 PkgModifier (unsigned short const &id
, const char * const alias
, Position
const &pos
) : ID(id
), Alias(alias
), Pos(pos
) {}
69 virtual bool PackageFromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
70 pkgCacheFile
&Cache
, const char * cmdline
,
71 std::list
<PkgModifier
> const &mods
);
73 // use PackageFrom(PACKAGENAME, …) instead
74 APT_DEPRECATED
pkgCache::PkgIterator
PackageFromName(pkgCacheFile
&Cache
, std::string
const &pattern
);
76 /** \brief be notified about the package being selected via pattern
78 * Main use is probably to show a message to the user what happened
80 * \param pkg is the package which was selected
81 * \param select is the selection method which choose the package
82 * \param pattern is the string used by the selection method to pick the package
84 virtual void showPackageSelection(pkgCache::PkgIterator
const &pkg
, PkgSelector
const select
, std::string
const &pattern
);
85 // use the method above instead, react only on the type you need and let the base handle the rest if need be
86 // this allows use to add new selection methods without breaking the ABI constantly with new virtual methods
87 APT_DEPRECATED
virtual void showTaskSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
88 APT_DEPRECATED
virtual void showRegExSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
89 APT_DEPRECATED
virtual void showFnmatchSelection(pkgCache::PkgIterator
const &pkg
, std::string
const &pattern
);
91 /** \brief be notified if a package can't be found via pattern
93 * Can be used to show a message as well as to try something else to make it match
95 * \param select is the method tried for selection
96 * \param pci is the container the package should be inserted in
97 * \param Cache is the package universe available
98 * \param pattern is the string not matching anything
100 virtual void canNotFindPackage(enum PkgSelector
const select
, PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
101 // same as above for showPackageSelection
102 APT_DEPRECATED
virtual void canNotFindTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
103 APT_DEPRECATED
virtual void canNotFindRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
104 APT_DEPRECATED
virtual void canNotFindFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
105 APT_DEPRECATED
virtual void canNotFindPackage(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &str
);
107 /** \brief specifies which version(s) we want to refer to */
109 /** by release string */
111 /** by version number string */
115 /** Candidate and installed version */
117 /** Candidate version */
119 /** Installed version */
121 /** Candidate or if non installed version */
123 /** Installed or if non candidate version */
125 /** Newest version */
129 /** \brief be notified about the version being selected via pattern
131 * Main use is probably to show a message to the user what happened
132 * Note that at the moment this method is only called for RELEASE
133 * and VERSION selections, not for the others.
135 * \param Pkg is the package which was selected for
136 * \param Ver is the version selected
137 * \param select is the selection method which choose the version
138 * \param pattern is the string used by the selection method to pick the version
140 virtual void showVersionSelection(pkgCache::PkgIterator
const &Pkg
, pkgCache::VerIterator
const &Ver
,
141 enum VerSelector
const select
, std::string
const &pattern
);
142 // renamed to have a similar interface to showPackageSelection
143 APT_DEPRECATED
virtual void showSelectedVersion(pkgCache::PkgIterator
const &Pkg
, pkgCache::VerIterator
const Ver
,
144 std::string
const &ver
, bool const verIsRel
);
146 /** \brief be notified if a version can't be found for a package
148 * Main use is probably to show a message to the user what happened
150 * \param select is the method tried for selection
151 * \param vci is the container the version should be inserted in
152 * \param Cache is the package universe available
153 * \param Pkg is the package we wanted a version from
155 virtual void canNotFindVersion(enum VerSelector
const select
, VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
156 // same as above for showPackageSelection
157 APT_DEPRECATED
virtual void canNotFindAllVer(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
158 APT_DEPRECATED
virtual void canNotFindInstCandVer(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
159 pkgCache::PkgIterator
const &Pkg
);
160 APT_DEPRECATED
virtual void canNotFindCandInstVer(VersionContainerInterface
* const vci
,
162 pkgCache::PkgIterator
const &Pkg
);
164 // the difference between canNotFind and canNotGet is that the later is more low-level
165 // and called from other places: In this case looking into the code is the only real answer…
166 virtual pkgCache::VerIterator
canNotGetVersion(enum VerSelector
const select
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
);
167 // same as above for showPackageSelection
168 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindNewestVer(pkgCacheFile
&Cache
,
169 pkgCache::PkgIterator
const &Pkg
);
170 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindCandidateVer(pkgCacheFile
&Cache
,
171 pkgCache::PkgIterator
const &Pkg
);
172 APT_DEPRECATED
virtual pkgCache::VerIterator
canNotFindInstalledVer(pkgCacheFile
&Cache
,
173 pkgCache::PkgIterator
const &Pkg
);
175 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
);
177 bool showErrors() const { return ShowError
; }
178 bool showErrors(bool const newValue
) { if (ShowError
== newValue
) return ShowError
; else return ((ShowError
= newValue
) == false); }
179 GlobalError::MsgType
errorType() const { return ErrorType
; }
180 GlobalError::MsgType
errorType(GlobalError::MsgType
const &newValue
)
182 if (ErrorType
== newValue
) return ErrorType
;
184 GlobalError::MsgType
const &oldValue
= ErrorType
;
185 ErrorType
= newValue
;
193 GlobalError::MsgType ErrorType
;
195 pkgCache::VerIterator
canNotGetInstCandVer(pkgCacheFile
&Cache
,
196 pkgCache::PkgIterator
const &Pkg
);
197 pkgCache::VerIterator
canNotGetCandInstVer(pkgCacheFile
&Cache
,
198 pkgCache::PkgIterator
const &Pkg
);
200 bool PackageFromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
201 bool PackageFromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
202 bool PackageFromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
203 bool PackageFromPackageName(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
);
204 bool PackageFromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
);
209 class PackageContainerInterface
{ /*{{{*/
210 /** \class PackageContainerInterface
212 * Interface ensuring that all operations can be executed on the yet to
213 * define concrete PackageContainer - access to all methods is possible,
214 * but in general the wrappers provided by the PackageContainer template
217 * This class mostly protects use from the need to write all implementation
218 * of the methods working on containers in the template */
220 class const_iterator
{ /*{{{*/
222 virtual pkgCache::PkgIterator
getPkg() const = 0;
223 operator pkgCache::PkgIterator(void) const { return getPkg(); }
225 inline const char *Name() const {return getPkg().Name(); }
226 inline std::string
FullName(bool const Pretty
) const { return getPkg().FullName(Pretty
); }
227 inline std::string
FullName() const { return getPkg().FullName(); }
228 APT_DEPRECATED
inline const char *Section() const {
229 APT_IGNORE_DEPRECATED_PUSH
230 return getPkg().Section();
231 APT_IGNORE_DEPRECATED_POP
233 inline bool Purge() const {return getPkg().Purge(); }
234 inline const char *Arch() const {return getPkg().Arch(); }
235 inline pkgCache::GrpIterator
Group() const { return getPkg().Group(); }
236 inline pkgCache::VerIterator
VersionList() const { return getPkg().VersionList(); }
237 inline pkgCache::VerIterator
CurrentVer() const { return getPkg().CurrentVer(); }
238 inline pkgCache::DepIterator
RevDependsList() const { return getPkg().RevDependsList(); }
239 inline pkgCache::PrvIterator
ProvidesList() const { return getPkg().ProvidesList(); }
240 inline pkgCache::PkgIterator::OkState
State() const { return getPkg().State(); }
241 inline const char *CandVersion() const { return getPkg().CandVersion(); }
242 inline const char *CurVersion() const { return getPkg().CurVersion(); }
243 inline pkgCache
*Cache() const { return getPkg().Cache(); }
244 inline unsigned long Index() const {return getPkg().Index();}
245 // we have only valid iterators here
246 inline bool end() const { return false; }
248 inline pkgCache::Package
const * operator->() const {return &*getPkg();}
252 virtual bool insert(pkgCache::PkgIterator
const &P
) = 0;
253 virtual bool empty() const = 0;
254 virtual void clear() = 0;
256 // FIXME: This is a bloody hack removed soon. Use CacheSetHelper::PkgSelector !
257 enum APT_DEPRECATED Constructor
{ UNKNOWN
= CacheSetHelper::UNKNOWN
,
258 REGEX
= CacheSetHelper::REGEX
,
259 TASK
= CacheSetHelper::TASK
,
260 FNMATCH
= CacheSetHelper::FNMATCH
};
261 APT_IGNORE_DEPRECATED_PUSH
262 void setConstructor(Constructor
const by
) { ConstructedBy
= (CacheSetHelper::PkgSelector
)by
; }
263 APT_IGNORE_DEPRECATED_POP
265 void setConstructor(CacheSetHelper::PkgSelector
const by
) { ConstructedBy
= by
; }
266 CacheSetHelper::PkgSelector
getConstructor() const { return ConstructedBy
; }
267 PackageContainerInterface();
268 explicit PackageContainerInterface(CacheSetHelper::PkgSelector
const by
);
269 PackageContainerInterface
& operator=(PackageContainerInterface
const &other
);
270 virtual ~PackageContainerInterface();
272 APT_DEPRECATED
static bool FromTask(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
273 return helper
.PackageFrom(CacheSetHelper::TASK
, pci
, Cache
, pattern
); }
274 APT_DEPRECATED
static bool FromRegEx(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
275 return helper
.PackageFrom(CacheSetHelper::REGEX
, pci
, Cache
, pattern
); }
276 APT_DEPRECATED
static bool FromFnmatch(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
277 return helper
.PackageFrom(CacheSetHelper::FNMATCH
, pci
, Cache
, pattern
); }
278 APT_DEPRECATED
static bool FromGroup(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string pattern
, CacheSetHelper
&helper
) {
279 return helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, pci
, Cache
, pattern
); }
280 APT_DEPRECATED
static bool FromString(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
281 return helper
.PackageFrom(CacheSetHelper::STRING
, pci
, Cache
, pattern
); }
282 APT_DEPRECATED
static bool FromCommandLine(PackageContainerInterface
* const pci
, pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
283 return helper
.PackageFromCommandLine(pci
, Cache
, cmdline
); }
285 APT_DEPRECATED
typedef CacheSetHelper::PkgModifier Modifier
;
287 APT_IGNORE_DEPRECATED_PUSH
288 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
289 return helper
.PackageFromName(Cache
, pattern
); }
290 APT_DEPRECATED
static bool FromModifierCommandLine(unsigned short &modID
, PackageContainerInterface
* const pci
,
291 pkgCacheFile
&Cache
, const char * cmdline
,
292 std::list
<Modifier
> const &mods
, CacheSetHelper
&helper
) {
293 return helper
.PackageFromModifierCommandLine(modID
, pci
, Cache
, cmdline
, mods
); }
294 APT_IGNORE_DEPRECATED_POP
297 CacheSetHelper::PkgSelector ConstructedBy
;
301 template<class Container
> class PackageContainer
: public PackageContainerInterface
{/*{{{*/
302 /** \class APT::PackageContainer
304 Simple wrapper around a container class like std::set to provide a similar
305 interface to a set of packages as to the complete set of all packages in the
309 /** \brief smell like a pkgCache::PkgIterator */
310 class const_iterator
: public PackageContainerInterface::const_iterator
,/*{{{*/
311 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {
312 typename
Container::const_iterator _iter
;
314 explicit const_iterator(typename
Container::const_iterator i
) : _iter(i
) {}
315 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
316 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
317 operator typename
Container::const_iterator(void) const { return _iter
; }
318 inline const_iterator
& operator++() { ++_iter
; return *this; }
319 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
320 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
321 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
322 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
324 class iterator
: public PackageContainerInterface::const_iterator
,
325 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
326 typename
Container::iterator _iter
;
328 explicit iterator(typename
Container::iterator i
) : _iter(i
) {}
329 pkgCache::PkgIterator
getPkg(void) const { return *_iter
; }
330 inline pkgCache::PkgIterator
operator*(void) const { return *_iter
; }
331 operator typename
Container::iterator(void) const { return _iter
; }
332 operator typename PackageContainer
<Container
>::const_iterator() { return typename PackageContainer
<Container
>::const_iterator(_iter
); }
333 inline iterator
& operator++() { ++_iter
; return *this; }
334 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
335 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
336 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
337 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
338 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
339 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
343 bool insert(pkgCache::PkgIterator
const &P
) { if (P
.end() == true) return false; _cont
.insert(P
); return true; }
344 template<class Cont
> void insert(PackageContainer
<Cont
> const &pkgcont
) { _cont
.insert((typename
Cont::const_iterator
)pkgcont
.begin(), (typename
Cont::const_iterator
)pkgcont
.end()); }
345 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
347 bool empty() const { return _cont
.empty(); }
348 void clear() { return _cont
.clear(); }
349 //FIXME: on ABI break, replace the first with the second without bool
350 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
351 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
352 size_t erase(const pkgCache::PkgIterator x
) { return _cont
.erase(x
); }
353 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
354 size_t size() const { return _cont
.size(); }
356 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
357 const_iterator
end() const { return const_iterator(_cont
.end()); }
358 iterator
begin() { return iterator(_cont
.begin()); }
359 iterator
end() { return iterator(_cont
.end()); }
360 const_iterator
find(pkgCache::PkgIterator
const &P
) const { return const_iterator(_cont
.find(P
)); }
362 PackageContainer() : PackageContainerInterface(CacheSetHelper::UNKNOWN
) {}
363 explicit PackageContainer(CacheSetHelper::PkgSelector
const &by
) : PackageContainerInterface(by
) {}
364 APT_IGNORE_DEPRECATED_PUSH
365 APT_DEPRECATED
PackageContainer(Constructor
const &by
) : PackageContainerInterface((CacheSetHelper::PkgSelector
)by
) {}
366 APT_IGNORE_DEPRECATED_POP
368 /** \brief sort all included versions with given comparer
370 Some containers are sorted by default, some are not and can't be,
371 but a few like std::vector can be sorted if need be, so this can be
372 specialized in later on. The default is that this will fail though.
373 Specifically, already sorted containers like std::set will return
374 false as well as there is no easy way to check that the given comparer
375 would sort in the same way the set is currently sorted
377 \return \b true if the set was sorted, \b false if not. */
378 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
380 /** \brief returns all packages in the cache who belong to the given task
382 A simple helper responsible for search for all members of a task
383 in the cache. Optional it prints a a notice about the
384 packages chosen cause of the given task.
385 \param Cache the packages are in
386 \param pattern name of the task
387 \param helper responsible for error and message handling */
388 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
389 PackageContainer
cont(CacheSetHelper::TASK
);
390 helper
.PackageFrom(CacheSetHelper::TASK
, &cont
, Cache
, pattern
);
393 static PackageContainer
FromTask(pkgCacheFile
&Cache
, std::string
const &pattern
) {
394 CacheSetHelper helper
;
395 return FromTask(Cache
, pattern
, helper
);
398 /** \brief returns all packages in the cache whose name matchs a given pattern
400 A simple helper responsible for executing a regular expression on all
401 package names in the cache. Optional it prints a a notice about the
402 packages chosen cause of the given package.
403 \param Cache the packages are in
404 \param pattern regular expression for package names
405 \param helper responsible for error and message handling */
406 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
407 PackageContainer
cont(CacheSetHelper::REGEX
);
408 helper
.PackageFrom(CacheSetHelper::REGEX
, &cont
, Cache
, pattern
);
412 static PackageContainer
FromRegEx(pkgCacheFile
&Cache
, std::string
const &pattern
) {
413 CacheSetHelper helper
;
414 return FromRegEx(Cache
, pattern
, helper
);
417 static PackageContainer
FromFnmatch(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
418 PackageContainer
cont(CacheSetHelper::FNMATCH
);
419 helper
.PackageFrom(CacheSetHelper::FNMATCH
, &cont
, Cache
, pattern
);
422 static PackageContainer
FromFnMatch(pkgCacheFile
&Cache
, std::string
const &pattern
) {
423 CacheSetHelper helper
;
424 return FromFnmatch(Cache
, pattern
, helper
);
427 APT_IGNORE_DEPRECATED_PUSH
428 /** \brief returns a package specified by a string
430 \param Cache the package is in
431 \param pattern String the package name should be extracted from
432 \param helper responsible for error and message handling */
433 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
434 return helper
.PackageFromName(Cache
, pattern
);
436 APT_DEPRECATED
static pkgCache::PkgIterator
FromName(pkgCacheFile
&Cache
, std::string
const &pattern
) {
437 CacheSetHelper helper
;
438 return FromName(Cache
, pattern
, helper
);
440 APT_IGNORE_DEPRECATED_POP
442 /** \brief returns all packages specified by a string
444 \param Cache the packages are in
445 \param pattern String the package name(s) should be extracted from
446 \param helper responsible for error and message handling */
447 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
, CacheSetHelper
&helper
) {
448 PackageContainer cont
;
449 helper
.PackageFrom(CacheSetHelper::PACKAGENAME
, &cont
, Cache
, pattern
);
452 static PackageContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pattern
) {
453 CacheSetHelper helper
;
454 return FromString(Cache
, pattern
, helper
);
457 /** \brief returns all packages specified on the commandline
459 Get all package names from the commandline and executes regex's if needed.
460 No special package command is supported, just plain names.
461 \param Cache the packages are in
462 \param cmdline Command line the package names should be extracted from
463 \param helper responsible for error and message handling */
464 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
, CacheSetHelper
&helper
) {
465 PackageContainer cont
;
466 helper
.PackageFromCommandLine(&cont
, Cache
, cmdline
);
469 static PackageContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
470 CacheSetHelper helper
;
471 return FromCommandLine(Cache
, cmdline
, helper
);
474 /** \brief group packages by a action modifiers
476 At some point it is needed to get from the same commandline
477 different package sets grouped by a modifier. Take
478 apt-get install apt awesome-
480 \param Cache the packages are in
481 \param cmdline Command line the package names should be extracted from
482 \param mods list of modifiers the method should accept
483 \param fallback the default modifier group for a package
484 \param helper responsible for error and message handling */
485 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
487 const char **cmdline
,
488 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
489 unsigned short const &fallback
,
490 CacheSetHelper
&helper
) {
491 std::map
<unsigned short, PackageContainer
> pkgsets
;
492 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
493 unsigned short modID
= fallback
;
494 PackageContainer pkgset
;
495 helper
.PackageFromModifierCommandLine(modID
, &pkgset
, Cache
, *I
, mods
);
496 pkgsets
[modID
].insert(pkgset
);
500 static std::map
<unsigned short, PackageContainer
> GroupedFromCommandLine(
502 const char **cmdline
,
503 std::list
<CacheSetHelper::PkgModifier
> const &mods
,
504 unsigned short const &fallback
) {
505 CacheSetHelper helper
;
506 return GroupedFromCommandLine(Cache
, cmdline
,
507 mods
, fallback
, helper
);
511 // specialisations for push_back containers: std::list & std::vector /*{{{*/
512 template<> template<class Cont
> void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
513 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
516 template<> template<class Cont
> void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(PackageContainer
<Cont
> const &pkgcont
) {
517 for (typename PackageContainer
<Cont
>::const_iterator p
= pkgcont
.begin(); p
!= pkgcont
.end(); ++p
)
520 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
521 // specializations again and again - but we need to see them, so that library users can use them
522 template<> inline bool PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
528 template<> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(pkgCache::PkgIterator
const &P
) {
534 template<> inline void PackageContainer
<std::list
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
535 for (const_iterator p
= begin
; p
!= end
; ++p
)
538 template<> inline void PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::insert(const_iterator begin
, const_iterator end
) {
539 for (const_iterator p
= begin
; p
!= end
; ++p
)
544 template<> template<class Compare
> inline bool PackageContainer
<std::vector
<pkgCache::PkgIterator
> >::sort(Compare Comp
) {
545 std::sort(_cont
.begin(), _cont
.end(), Comp
);
549 // class PackageUniverse - pkgCache as PackageContainerInterface /*{{{*/
550 /** \class PackageUniverse
552 Wraps around our usual pkgCache, so that it can be stuffed into methods
553 expecting a PackageContainer.
555 The wrapping is read-only in practice modeled by making erase and co
557 class APT_HIDDEN PackageUniverse
: public PackageContainerInterface
{
558 pkgCache
* const _cont
;
561 typedef pkgCache::PkgIterator iterator
;
562 typedef pkgCache::PkgIterator const_iterator
;
564 APT_PUBLIC
bool empty() const { return false; }
565 APT_PUBLIC
size_t size() const { return _cont
->Head().PackageCount
; }
567 APT_PUBLIC const_iterator
begin() const { return _cont
->PkgBegin(); }
568 APT_PUBLIC const_iterator
end() const { return _cont
->PkgEnd(); }
569 APT_PUBLIC iterator
begin() { return _cont
->PkgBegin(); }
570 APT_PUBLIC iterator
end() { return _cont
->PkgEnd(); }
572 explicit APT_PUBLIC
PackageUniverse(pkgCache
* const Owner
);
573 APT_PUBLIC
virtual ~PackageUniverse();
576 bool insert(pkgCache::PkgIterator
const &) { return true; }
577 template<class Cont
> void insert(PackageContainer
<Cont
> const &) { }
578 void insert(const_iterator
, const_iterator
) { }
581 iterator
& erase(iterator
&iter
) { return iter
; }
582 size_t erase(const pkgCache::PkgIterator
) { return 0; }
583 void erase(iterator
, iterator
) { }
586 typedef PackageContainer
<std::set
<pkgCache::PkgIterator
> > PackageSet
;
587 typedef PackageContainer
<std::list
<pkgCache::PkgIterator
> > PackageList
;
588 typedef PackageContainer
<std::vector
<pkgCache::PkgIterator
> > PackageVector
;
590 class VersionContainerInterface
{ /*{{{*/
591 /** \class APT::VersionContainerInterface
593 Same as APT::PackageContainerInterface, just for Versions */
595 /** \brief smell like a pkgCache::VerIterator */
596 class const_iterator
{ /*{{{*/
598 virtual pkgCache::VerIterator
getVer() const = 0;
599 operator pkgCache::VerIterator(void) { return getVer(); }
601 inline pkgCache
*Cache() const { return getVer().Cache(); }
602 inline unsigned long Index() const {return getVer().Index();}
603 inline int CompareVer(const pkgCache::VerIterator
&B
) const { return getVer().CompareVer(B
); }
604 inline const char *VerStr() const { return getVer().VerStr(); }
605 inline const char *Section() const { return getVer().Section(); }
606 inline const char *Arch() const { return getVer().Arch(); }
607 inline pkgCache::PkgIterator
ParentPkg() const { return getVer().ParentPkg(); }
608 inline pkgCache::DescIterator
DescriptionList() const { return getVer().DescriptionList(); }
609 inline pkgCache::DescIterator
TranslatedDescription() const { return getVer().TranslatedDescription(); }
610 inline pkgCache::DepIterator
DependsList() const { return getVer().DependsList(); }
611 inline pkgCache::PrvIterator
ProvidesList() const { return getVer().ProvidesList(); }
612 inline pkgCache::VerFileIterator
FileList() const { return getVer().FileList(); }
613 inline bool Downloadable() const { return getVer().Downloadable(); }
614 inline const char *PriorityType() const { return getVer().PriorityType(); }
615 inline std::string
RelStr() const { return getVer().RelStr(); }
616 inline bool Automatic() const { return getVer().Automatic(); }
617 inline pkgCache::VerFileIterator
NewestFile() const { return getVer().NewestFile(); }
618 // we have only valid iterators here
619 inline bool end() const { return false; }
621 inline pkgCache::Version
const * operator->() const { return &*getVer(); }
625 virtual bool insert(pkgCache::VerIterator
const &V
) = 0;
626 virtual bool empty() const = 0;
627 virtual void clear() = 0;
629 /** \brief specifies which version(s) will be returned if non is given */
630 enum APT_DEPRECATED Version
{
631 ALL
= CacheSetHelper::ALL
,
632 CANDANDINST
= CacheSetHelper::CANDANDINST
,
633 CANDIDATE
= CacheSetHelper::CANDIDATE
,
634 INSTALLED
= CacheSetHelper::INSTALLED
,
635 CANDINST
= CacheSetHelper::CANDINST
,
636 INSTCAND
= CacheSetHelper::INSTCAND
,
637 NEWEST
= CacheSetHelper::NEWEST
641 unsigned short const ID
;
642 const char * const Alias
;
643 enum Position
{ NONE
, PREFIX
, POSTFIX
} const Pos
;
644 enum CacheSetHelper::VerSelector
const SelectVersion
;
645 Modifier (unsigned short const &id
, const char * const alias
, Position
const &pos
,
646 enum CacheSetHelper::VerSelector
const select
) : ID(id
), Alias(alias
), Pos(pos
),
647 SelectVersion(select
) {}
648 APT_IGNORE_DEPRECATED_PUSH
649 APT_DEPRECATED
Modifier(unsigned short const &id
, const char * const alias
, Position
const &pos
,
650 Version
const &select
) : ID(id
), Alias(alias
), Pos(pos
),
651 SelectVersion((CacheSetHelper::VerSelector
)select
) {}
652 APT_IGNORE_DEPRECATED_POP
655 static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
656 const char **cmdline
, CacheSetHelper::VerSelector
const fallback
,
657 CacheSetHelper
&helper
);
658 APT_IGNORE_DEPRECATED_PUSH
659 APT_DEPRECATED
static bool FromCommandLine(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
660 const char **cmdline
, Version
const &fallback
,
661 CacheSetHelper
&helper
) {
662 return FromCommandLine(vci
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
664 APT_IGNORE_DEPRECATED_POP
666 static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
667 std::string pkg
, CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
668 bool const onlyFromName
= false);
669 APT_IGNORE_DEPRECATED_PUSH
670 APT_DEPRECATED
static bool FromString(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
671 std::string pkg
, Version
const &fallback
, CacheSetHelper
&helper
,
672 bool const onlyFromName
= false) {
673 return FromString(vci
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
, onlyFromName
);
675 APT_IGNORE_DEPRECATED_POP
677 static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
678 pkgCache::PkgIterator
const &P
, CacheSetHelper::VerSelector
const fallback
,
679 CacheSetHelper
&helper
);
680 APT_IGNORE_DEPRECATED_PUSH
681 APT_DEPRECATED
static bool FromPackage(VersionContainerInterface
* const vci
, pkgCacheFile
&Cache
,
682 pkgCache::PkgIterator
const &P
, Version
const &fallback
,
683 CacheSetHelper
&helper
) {
684 return FromPackage(vci
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
686 APT_IGNORE_DEPRECATED_POP
688 static bool FromModifierCommandLine(unsigned short &modID
,
689 VersionContainerInterface
* const vci
,
690 pkgCacheFile
&Cache
, const char * cmdline
,
691 std::list
<Modifier
> const &mods
,
692 CacheSetHelper
&helper
);
695 static bool FromDependency(VersionContainerInterface
* const vci
,
697 pkgCache::DepIterator
const &D
,
698 CacheSetHelper::VerSelector
const selector
,
699 CacheSetHelper
&helper
);
700 APT_IGNORE_DEPRECATED_PUSH
701 APT_DEPRECATED
static bool FromDependency(VersionContainerInterface
* const vci
,
703 pkgCache::DepIterator
const &D
,
704 Version
const &selector
,
705 CacheSetHelper
&helper
) {
706 return FromDependency(vci
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
708 APT_IGNORE_DEPRECATED_POP
710 VersionContainerInterface();
711 VersionContainerInterface
& operator=(VersionContainerInterface
const &other
);
712 virtual ~VersionContainerInterface();
718 /** \brief returns the candidate version of the package
720 \param Cache to be used to query for information
721 \param Pkg we want the candidate version from this package
722 \param helper used in this container instance */
723 static pkgCache::VerIterator
getCandidateVer(pkgCacheFile
&Cache
,
724 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
726 /** \brief returns the installed version of the package
728 \param Cache to be used to query for information
729 \param Pkg we want the installed version from this package
730 \param helper used in this container instance */
731 static pkgCache::VerIterator
getInstalledVer(pkgCacheFile
&Cache
,
732 pkgCache::PkgIterator
const &Pkg
, CacheSetHelper
&helper
);
736 template<class Container
> class VersionContainer
: public VersionContainerInterface
{/*{{{*/
737 /** \class APT::VersionContainer
739 Simple wrapper around a container class like std::set to provide a similar
740 interface to a set of versions as to the complete set of all versions in the
744 /** \brief smell like a pkgCache::VerIterator */
745 class const_iterator
: public VersionContainerInterface::const_iterator
,
746 public std::iterator
<std::forward_iterator_tag
, typename
Container::const_iterator
> {/*{{{*/
747 typename
Container::const_iterator _iter
;
749 explicit const_iterator(typename
Container::const_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::const_iterator(void) const { return _iter
; }
753 inline const_iterator
& operator++() { ++_iter
; return *this; }
754 inline const_iterator
operator++(int) { const_iterator
tmp(*this); operator++(); return tmp
; }
755 inline bool operator!=(const_iterator
const &i
) const { return _iter
!= i
._iter
; }
756 inline bool operator==(const_iterator
const &i
) const { return _iter
== i
._iter
; }
757 friend std::ostream
& operator<<(std::ostream
& out
, const_iterator i
) { return operator<<(out
, *i
); }
759 class iterator
: public VersionContainerInterface::const_iterator
,
760 public std::iterator
<std::forward_iterator_tag
, typename
Container::iterator
> {
761 typename
Container::iterator _iter
;
763 explicit iterator(typename
Container::iterator i
) : _iter(i
) {}
764 pkgCache::VerIterator
getVer(void) const { return *_iter
; }
765 inline pkgCache::VerIterator
operator*(void) const { return *_iter
; }
766 operator typename
Container::iterator(void) const { return _iter
; }
767 operator typename VersionContainer
<Container
>::const_iterator() { return typename VersionContainer
<Container
>::const_iterator(_iter
); }
768 inline iterator
& operator++() { ++_iter
; return *this; }
769 inline iterator
operator++(int) { iterator
tmp(*this); operator++(); return tmp
; }
770 inline bool operator!=(iterator
const &i
) const { return _iter
!= i
._iter
; }
771 inline bool operator==(iterator
const &i
) const { return _iter
== i
._iter
; }
772 inline iterator
& operator=(iterator
const &i
) { _iter
= i
._iter
; return *this; }
773 inline iterator
& operator=(typename
Container::iterator
const &i
) { _iter
= i
; return *this; }
774 friend std::ostream
& operator<<(std::ostream
& out
, iterator i
) { return operator<<(out
, *i
); }
778 bool insert(pkgCache::VerIterator
const &V
) { if (V
.end() == true) return false; _cont
.insert(V
); return true; }
779 template<class Cont
> void insert(VersionContainer
<Cont
> const &vercont
) { _cont
.insert((typename
Cont::const_iterator
)vercont
.begin(), (typename
Cont::const_iterator
)vercont
.end()); }
780 void insert(const_iterator begin
, const_iterator end
) { _cont
.insert(begin
, end
); }
781 bool empty() const { return _cont
.empty(); }
782 void clear() { return _cont
.clear(); }
783 //FIXME: on ABI break, replace the first with the second without bool
784 void erase(iterator position
) { _cont
.erase((typename
Container::iterator
)position
); }
785 iterator
& erase(iterator
&position
, bool) { return position
= _cont
.erase((typename
Container::iterator
)position
); }
786 size_t erase(const pkgCache::VerIterator x
) { return _cont
.erase(x
); }
787 void erase(iterator first
, iterator last
) { _cont
.erase(first
, last
); }
788 size_t size() const { return _cont
.size(); }
790 const_iterator
begin() const { return const_iterator(_cont
.begin()); }
791 const_iterator
end() const { return const_iterator(_cont
.end()); }
792 iterator
begin() { return iterator(_cont
.begin()); }
793 iterator
end() { return iterator(_cont
.end()); }
794 const_iterator
find(pkgCache::VerIterator
const &V
) const { return const_iterator(_cont
.find(V
)); }
796 /** \brief sort all included versions with given comparer
798 Some containers are sorted by default, some are not and can't be,
799 but a few like std::vector can be sorted if need be, so this can be
800 specialized in later on. The default is that this will fail though.
801 Specifically, already sorted containers like std::set will return
802 false as well as there is no easy way to check that the given comparer
803 would sort in the same way the set is currently sorted
805 \return \b true if the set was sorted, \b false if not. */
806 template<class Compare
> bool sort(Compare
/*Comp*/) { return false; }
808 /** \brief returns all versions specified on the commandline
810 Get all versions from the commandline, uses given default version if
811 non specifically requested and executes regex's if needed on names.
812 \param Cache the packages and versions are in
813 \param cmdline Command line the versions should be extracted from
814 \param fallback version specification
815 \param helper responsible for error and message handling */
816 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
817 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
818 VersionContainer vercon
;
819 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, fallback
, helper
);
822 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
823 CacheSetHelper::VerSelector
const fallback
) {
824 CacheSetHelper helper
;
825 return FromCommandLine(Cache
, cmdline
, fallback
, helper
);
827 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
) {
828 return FromCommandLine(Cache
, cmdline
, CacheSetHelper::CANDINST
);
830 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
831 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
,
832 bool const /*onlyFromName = false*/) {
833 VersionContainer vercon
;
834 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, fallback
, helper
);
837 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
838 CacheSetHelper::VerSelector
const fallback
) {
839 CacheSetHelper helper
;
840 return FromString(Cache
, pkg
, fallback
, helper
);
842 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
) {
843 return FromString(Cache
, pkg
, CacheSetHelper::CANDINST
);
845 APT_IGNORE_DEPRECATED_PUSH
846 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
847 Version
const &fallback
, CacheSetHelper
&helper
) {
848 VersionContainer vercon
;
849 VersionContainerInterface::FromCommandLine(&vercon
, Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
852 static VersionContainer
FromCommandLine(pkgCacheFile
&Cache
, const char **cmdline
,
853 Version
const &fallback
) {
854 CacheSetHelper helper
;
855 return FromCommandLine(Cache
, cmdline
, (CacheSetHelper::VerSelector
)fallback
, helper
);
857 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string
const &pkg
,
858 Version
const &fallback
, CacheSetHelper
&helper
,
859 bool const /*onlyFromName = false*/) {
860 VersionContainer vercon
;
861 VersionContainerInterface::FromString(&vercon
, Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
864 static VersionContainer
FromString(pkgCacheFile
&Cache
, std::string pkg
,
865 Version
const &fallback
) {
866 CacheSetHelper helper
;
867 return FromString(Cache
, pkg
, (CacheSetHelper::VerSelector
)fallback
, helper
);
869 APT_IGNORE_DEPRECATED_POP
871 /** \brief returns all versions specified for the package
873 \param Cache the package and versions are in
874 \param P the package in question
875 \param fallback the version(s) you want to get
876 \param helper the helper used for display and error handling */
877 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
878 CacheSetHelper::VerSelector
const fallback
, CacheSetHelper
&helper
) {
879 VersionContainer vercon
;
880 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, fallback
, helper
);
883 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
884 CacheSetHelper::VerSelector
const fallback
) {
885 CacheSetHelper helper
;
886 return FromPackage(Cache
, P
, fallback
, helper
);
888 APT_IGNORE_DEPRECATED_PUSH
889 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
890 Version
const &fallback
, CacheSetHelper
&helper
) {
891 VersionContainer vercon
;
892 VersionContainerInterface::FromPackage(&vercon
, Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
895 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
,
896 Version
const &fallback
) {
897 CacheSetHelper helper
;
898 return FromPackage(Cache
, P
, (CacheSetHelper::VerSelector
)fallback
, helper
);
900 APT_IGNORE_DEPRECATED_POP
901 static VersionContainer
FromPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &P
) {
902 return FromPackage(Cache
, P
, CacheSetHelper::CANDIDATE
);
905 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
907 const char **cmdline
,
908 std::list
<Modifier
> const &mods
,
909 unsigned short const fallback
,
910 CacheSetHelper
&helper
) {
911 std::map
<unsigned short, VersionContainer
> versets
;
912 for (const char **I
= cmdline
; *I
!= 0; ++I
) {
913 unsigned short modID
= fallback
;
914 VersionContainer verset
;
915 VersionContainerInterface::FromModifierCommandLine(modID
, &verset
, Cache
, *I
, mods
, helper
);
916 versets
[modID
].insert(verset
);
921 static std::map
<unsigned short, VersionContainer
> GroupedFromCommandLine(
922 pkgCacheFile
&Cache
, const char **cmdline
,
923 std::list
<Modifier
> const &mods
,
924 unsigned short const fallback
) {
925 CacheSetHelper helper
;
926 return GroupedFromCommandLine(Cache
, cmdline
,
927 mods
, fallback
, helper
);
930 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
931 CacheSetHelper::VerSelector
const selector
, CacheSetHelper
&helper
) {
932 VersionContainer vercon
;
933 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, selector
, helper
);
936 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
937 CacheSetHelper::VerSelector
const selector
) {
938 CacheSetHelper helper
;
939 return FromPackage(Cache
, D
, selector
, helper
);
941 APT_IGNORE_DEPRECATED_PUSH
942 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
943 Version
const &selector
, CacheSetHelper
&helper
) {
944 VersionContainer vercon
;
945 VersionContainerInterface::FromDependency(&vercon
, Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
948 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
,
949 Version
const &selector
) {
950 CacheSetHelper helper
;
951 return FromPackage(Cache
, D
, (CacheSetHelper::VerSelector
)selector
, helper
);
953 APT_IGNORE_DEPRECATED_POP
954 static VersionContainer
FromDependency(pkgCacheFile
&Cache
, pkgCache::DepIterator
const &D
) {
955 return FromPackage(Cache
, D
, CacheSetHelper::CANDIDATE
);
959 // specialisations for push_back containers: std::list & std::vector /*{{{*/
960 template<> template<class Cont
> void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
961 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
964 template<> template<class Cont
> void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(VersionContainer
<Cont
> const &vercont
) {
965 for (typename VersionContainer
<Cont
>::const_iterator v
= vercont
.begin(); v
!= vercont
.end(); ++v
)
968 // these two are 'inline' as otherwise the linker has problems with seeing these untemplated
969 // specializations again and again - but we need to see them, so that library users can use them
970 template<> inline bool VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
976 template<> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(pkgCache::VerIterator
const &V
) {
982 template<> inline void VersionContainer
<std::list
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
983 for (const_iterator v
= begin
; v
!= end
; ++v
)
986 template<> inline void VersionContainer
<std::vector
<pkgCache::VerIterator
> >::insert(const_iterator begin
, const_iterator end
) {
987 for (const_iterator v
= begin
; v
!= end
; ++v
)
992 template<> template<class Compare
> inline bool VersionContainer
<std::vector
<pkgCache::VerIterator
> >::sort(Compare Comp
) {
993 std::sort(_cont
.begin(), _cont
.end(), Comp
);
997 typedef VersionContainer
<std::set
<pkgCache::VerIterator
> > VersionSet
;
998 typedef VersionContainer
<std::list
<pkgCache::VerIterator
> > VersionList
;
999 typedef VersionContainer
<std::vector
<pkgCache::VerIterator
> > VersionVector
;