apt 3.1.8 commandline package manager

cacheiterators.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Cache Iterators - Iterators for navigating the cache structure
6
7 The iterators all provides ++,==,!=,->,* and end for their type.
8 The end function can be used to tell if the list has been fully
9 traversed.
10
11 Unlike STL iterators these contain helper functions to access the data
12 that is being iterated over. This is because the data structures can't
13 be formed in a manner that is intuitive to use and also mmapable.
14
15 For each variable in the target structure that would need a translation
16 to be accessed correctly a translating function of the same name is
17 present in the iterator. If applicable the translating function will
18 return an iterator.
19
20 The DepIterator can iterate over two lists, a list of 'version depends'
21 or a list of 'package reverse depends'. The type is determined by the
22 structure passed to the constructor, which should be the structure
23 that has the depends pointer as a member. The provide iterator has the
24 same system.
25
26 This header is not user includable, please use apt-pkg/pkgcache.h
27
28 ##################################################################### */
29 /*}}}*/
30#ifndef PKGLIB_CACHEITERATORS_H
31#define PKGLIB_CACHEITERATORS_H
32#ifndef __PKGLIB_IN_PKGCACHE_H
33#warning apt-pkg/cacheiterators.h should not be included directly, include apt-pkg/pkgcache.h instead
34#endif
35#include <apt-pkg/macros.h>
36
37#include <iosfwd>
38#include <iterator>
39#include <string>
40#include <string_view>
41
42#include <cstring>
43
44// abstract Iterator template /*{{{*/
45/* This template provides the very basic iterator methods we
46 need to have for doing some walk-over-the-cache magic */
47 template<typename Str, typename Itr> class APT_PUBLIC pkgCache::Iterator {
56 Str* OwnerPointer() const { return static_cast<Itr const*>(this)->OwnerPointer(); }
57
58 protected:
59 Str *S;
60 pkgCache *Owner;
61
62 public:
63 // iterator_traits
64 using iterator_category = std::forward_iterator_tag;
65 using value_type = Str;
66 using difference_type = std::ptrdiff_t;
67 using pointer = Str*;
68 using reference = Str&;
69 // Iteration
70 inline bool end() const {return Owner == 0 || S == OwnerPointer();}
71
72 // Comparison
73 inline bool operator ==(const Itr &B) const {return S == B.S;}
74 inline bool operator !=(const Itr &B) const {return S != B.S;}
75
76 // Accessors
77 inline Str *operator ->() {return S;}
78 inline Str const *operator ->() const {return S;}
79 inline operator Str *() {return S == OwnerPointer() ? 0 : S;}
80 inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;}
81 inline Str &operator *() {return *S;}
82 inline Str const &operator *() const {return *S;}
83 inline pkgCache *Cache() const {return Owner;}
84
85 // Mixed stuff
86 inline bool IsGood() const { return S && Owner && ! end();}
87 inline unsigned long Index() const {return S - OwnerPointer();}
88 inline map_pointer<Str> MapPointer() const {return map_pointer<Str>(Index()) ;}
89
90 void ReMap(void const * const oldMap, void * const newMap) {
91 if (Owner == 0 || S == 0)
92 return;
93 S = static_cast<Str *>(newMap) + (S - static_cast<Str const *>(oldMap));
94 }
95
96 // Constructors - look out for the variable assigning
97 inline Iterator() : S(0), Owner(0) {}
98 inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {}
99};
100 /*}}}*/
101// Group Iterator /*{{{*/
102/* Packages with the same name are collected in a Group so someone only
103 interest in package names can iterate easily over the names, so the
104 different architectures can be treated as of the "same" package
105 (apt internally treat them as totally different packages) */
106 class APT_PUBLIC pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
107 long HashIndex;
108
109 public:
110 inline Group* OwnerPointer() const {
111 return (Owner != 0) ? Owner->GrpP : 0;
112 }
113
114 // This constructor is the 'begin' constructor, never use it.
115 explicit inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
116 S = OwnerPointer();
117 operator++();
118 }
119
120 GrpIterator& operator++();
121 inline GrpIterator operator++(int) { GrpIterator const tmp(*this); operator++(); return tmp; }
122
123 inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}
124 inline PkgIterator PackageList() const;
125 inline VerIterator VersionsInSource() const;
126 PkgIterator FindPkg(std::string_view Arch = {"any", 3}) const;
134 PkgIterator FindPreferredPkg(bool const &PreferNonVirtual = true) const;
135 PkgIterator NextPkg(PkgIterator const &Pkg) const;
136
137 // Constructors
138 inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
139 if (S == 0)
140 S = OwnerPointer();
141 }
142 inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {}
143
144};
145 /*}}}*/
146// Package Iterator /*{{{*/
147 class APT_PUBLIC pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
148 long HashIndex;
149
150 public:
151 inline Package* OwnerPointer() const {
152 return (Owner != 0) ? Owner->PkgP : 0;
153 }
154
155 // This constructor is the 'begin' constructor, never use it.
156 explicit inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator>(Owner), HashIndex(-1) {
157 S = OwnerPointer();
158 operator++();
159 }
160
161 PkgIterator& operator++();
162 inline PkgIterator operator++(int) { PkgIterator const tmp(*this); operator++(); return tmp; }
163
164 enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
165
166 // Accessors
167 inline const char *Name() const { return Group().Name(); }
168 inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
169 (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
170 inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}
171 inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
172
173 inline VerIterator VersionList() const APT_PURE;
174 inline VerIterator CurrentVer() const APT_PURE;
175 inline DepIterator RevDependsList() const APT_PURE;
176 inline PrvIterator ProvidesList() const APT_PURE;
177 OkState State() const APT_PURE;
178 const char *CurVersion() const APT_PURE;
179
180 // for a nice printable representation you likely want APT::PrettyPkg instead
181 friend std::ostream& operator<<(std::ostream& out, PkgIterator i);
182 std::string FullName(bool const &Pretty = false) const;
183
184 // Constructors
185 inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
186 if (S == 0)
187 S = OwnerPointer();
188 }
189 inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {}
190};
191 /*}}}*/
192// SourceVersion Iterator /*{{{*/
193 class APT_PUBLIC pkgCache::SrcVerIterator : public Iterator<SourceVersion, SrcVerIterator>
194{
195 public:
196 inline SourceVersion *OwnerPointer() const
197 {
198 return (Owner != 0) ? Owner->SrcVerP : 0;
199 }
200#if 0
201 // Iteration
202 inline SrcVerIterator& operator++() {if (S != Owner->SrcVerP) S = Owner->SrcVerP + S->NextSourceVersion; return *this;}
203 inline SrcVerIterator operator++(int) { SrcVerIterator const tmp(*this); operator++(); return tmp; }
204#endif
205 inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group); }
206 inline const char *VerStr() const { return S->VerStr == 0 ? 0 : Owner->StrP + S->VerStr; }
207
208 inline SrcVerIterator(pkgCache &Owner, SourceVersion *Trg = 0) : Iterator<SourceVersion, SrcVerIterator>(Owner, Trg)
209 {
210 if (S == 0)
211 S = OwnerPointer();
212 }
213 inline SrcVerIterator() : Iterator<SourceVersion, SrcVerIterator>() {}
214};
215 /*}}}*/
216
217// Version Iterator /*{{{*/
218 class APT_PUBLIC pkgCache::VerIterator : public Iterator<Version, VerIterator> {
219 public:
220 inline Version* OwnerPointer() const {
221 return (Owner != 0) ? Owner->VerP : 0;
222 }
223
224 // Iteration
225 inline VerIterator& operator++() {if (S != Owner->VerP) S = Owner->VerP + S->NextVer; return *this;}
226 inline VerIterator operator++(int) { VerIterator const tmp(*this); operator++(); return tmp; }
227
228 inline VerIterator NextInSource()
229 {
230 if (S != Owner->VerP)
231 S = Owner->VerP + S->NextInSource;
232 return *this;
233 }
234
235 // Comparison
236 int CompareVer(const VerIterator &B) const;
241 inline bool SimilarVer(const VerIterator &B) const {
242 return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
243 }
244
245 // Accessors
246 inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}
247 inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
250 SrcVerIterator SourceVersion() const { return SrcVerIterator(*Owner, Owner->SrcVerP + S->SourceVersion); }
253 inline const char *SourcePkgName() const { return SourceVersion().Group().Name(); }
256 inline const char *SourceVerStr() const { return SourceVersion().VerStr(); }
257 inline const char *Arch() const {
258 if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All)
259 return "all";
260 return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
261 }
262 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
263
264 inline DescIterator DescriptionList() const;
265 DescIterator TranslatedDescriptionForLanguage(std::string_view lang) const;
266 DescIterator TranslatedDescription() const;
267 inline DepIterator DependsList() const;
268 inline PrvIterator ProvidesList() const;
269 inline VerFileIterator FileList() const;
270 bool Downloadable() const;
271 inline const char *PriorityType() const {return Owner->Priority(S->Priority);}
272 const char *MultiArchType() const APT_PURE;
273 std::string RelStr() const;
274
275 bool Automatic() const;
276 VerFileIterator NewestFile() const;
277 bool IsSecurityUpdate() const;
278
279#ifdef APT_COMPILING_APT
280 inline unsigned int PhasedUpdatePercentage() const
281 {
282 return (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage;
283 }
284 inline bool PhasedUpdatePercentage(unsigned int percentage)
285 {
286 if (percentage > 100)
287 return false;
288 (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage = static_cast<uint8_t>(percentage);
289 return true;
290 }
291#endif
292
293 inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
294 if (S == 0)
295 S = OwnerPointer();
296 }
297 inline VerIterator() : Iterator<Version, VerIterator>() {}
298};
299 /*}}}*/
300// Description Iterator /*{{{*/
301 class APT_PUBLIC pkgCache::DescIterator : public Iterator<Description, DescIterator> {
302 public:
303 inline Description* OwnerPointer() const {
304 return (Owner != 0) ? Owner->DescP : 0;
305 }
306
307 // Iteration
308 inline DescIterator& operator++() {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc; return *this;}
309 inline DescIterator operator++(int) { DescIterator const tmp(*this); operator++(); return tmp; }
310
311 // Comparison
312 int CompareDesc(const DescIterator &B) const;
313
314 // Accessors
315 inline const char *LanguageCode() const {return Owner->StrP + S->language_code;}
316 inline const char *md5() const {return Owner->StrP + S->md5sum;}
317 inline DescFileIterator FileList() const;
318
319 inline DescIterator() : Iterator<Description, DescIterator>() {}
320 inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
321 if (S == 0)
322 S = Owner.DescP;
323 }
324};
325 /*}}}*/
326// Dependency iterator /*{{{*/
327 class APT_PUBLIC pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
328 enum {DepVer, DepRev} Type;
329 DependencyData * S2;
330
331 public:
332 inline Dependency* OwnerPointer() const {
333 return (Owner != 0) ? Owner->DepP : 0;
334 }
335
336 // Iteration
337 DepIterator& operator++();
338 inline DepIterator operator++(int) { DepIterator const tmp(*this); operator++(); return tmp; }
339
340 // Accessors
341 inline const char *TargetVer() const {return S2->Version == 0?0:Owner->StrP + S2->Version;}
342 inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S2->Package);}
343 inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}
344 inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
345 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->ParentVer)].ParentPkg);}
346 inline bool Reverse() const {return Type == DepRev;}
347 bool IsCritical() const APT_PURE;
348 bool IsNegative() const APT_PURE;
349 bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
350 bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
351 /* MultiArch can be translated to SingleArch for an resolver and we did so,
352 by adding dependencies to help the resolver understand the problem, but
353 sometimes it is needed to identify these to ignore them… */
354 inline bool IsMultiArchImplicit() const APT_PURE {
355 return (S2->CompareOp & pkgCache::Dep::MultiArchImplicit) == pkgCache::Dep::MultiArchImplicit;
356 }
357 /* This covers additionally negative dependencies, which aren't arch-specific,
358 but change architecture nonetheless as a Conflicts: foo does applies for all archs */
359 bool IsImplicit() const APT_PURE;
360
361 bool IsSatisfied(PkgIterator const &Pkg) const APT_PURE;
362 bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
363 bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
364 void GlobOr(DepIterator &Start,DepIterator &End);
365 Version **AllTargets() const;
366 bool SmartTargetPkg(PkgIterator &Result) const;
367 inline const char *CompType() const {return Owner->CompType(S2->CompareOp);}
368 inline const char *DepType() const {return Owner->DepType(S2->Type);}
369
370 // overrides because we are special
371 struct DependencyProxy
372 {
373 map_stringitem_t &Version;
374 map_pointer<pkgCache::Package> &Package;
375 map_id_t &ID;
376 unsigned char &Type;
377 unsigned char &CompareOp;
378 map_pointer<pkgCache::Version> &ParentVer;
379 map_pointer<pkgCache::DependencyData> &DependencyData;
380 map_pointer<Dependency> &NextRevDepends;
381 map_pointer<Dependency> &NextDepends;
382 map_pointer<pkgCache::DependencyData> &NextData;
383 DependencyProxy const * operator->() const { return this; }
384 DependencyProxy * operator->() { return this; }
385 };
386 inline DependencyProxy operator->() const {return (DependencyProxy) { S2->Version, S2->Package, S->ID, S2->Type, S2->CompareOp, S->ParentVer, S->DependencyData, S->NextRevDepends, S->NextDepends, S2->NextData };}
387 inline DependencyProxy operator->() {return (DependencyProxy) { S2->Version, S2->Package, S->ID, S2->Type, S2->CompareOp, S->ParentVer, S->DependencyData, S->NextRevDepends, S->NextDepends, S2->NextData };}
388 void ReMap(void const * const oldMap, void * const newMap)
389 {
390 Iterator<Dependency, DepIterator>::ReMap(oldMap, newMap);
391 if (Owner == 0 || S == 0 || S2 == 0)
392 return;
393 S2 = static_cast<DependencyData *>(newMap) + (S2 - static_cast<DependencyData const *>(oldMap));
394 }
395
396 // for a nice printable representation you likely want APT::PrettyDep instead
397 friend std::ostream& operator<<(std::ostream& out, DepIterator D);
398
399 inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
400 Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
401 if (S == 0)
402 S = Owner.DepP;
403 }
404 inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
405 Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
406 if (S == 0)
407 S = Owner.DepP;
408 }
409 inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer), S2(0) {}
410};
411 /*}}}*/
412// Provides iterator /*{{{*/
413 class APT_PUBLIC pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
414 enum {PrvVer, PrvPkg} Type;
415
416 public:
417 inline Provides* OwnerPointer() const {
418 return (Owner != 0) ? Owner->ProvideP : 0;
419 }
420
421 // Iteration
422 inline PrvIterator& operator ++() {
423 if (S != Owner->ProvideP)
424 S = Owner->ProvideP + (Type == PrvVer ? S->NextPkgProv : S->NextProvides);
425 return *this;
426 }
427 inline PrvIterator operator++(int) { PrvIterator const tmp(*this); operator++(); return tmp; }
428
429 // Accessors
430 inline const char *Name() const {return ParentPkg().Name();}
431 inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
432 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
433 inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}
434 inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->Version)].ParentPkg);}
435
436 /* MultiArch can be translated to SingleArch for an resolver and we did so,
437 by adding provides to help the resolver understand the problem, but
438 sometimes it is needed to identify these to ignore them… */
439 bool IsMultiArchImplicit() const APT_PURE
440 { return (S->Flags & pkgCache::Flag::MultiArchImplicit) == pkgCache::Flag::MultiArchImplicit; }
441
442
443 inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
444 inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
445 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
446 if (S == 0)
447 S = Owner.ProvideP;
448 }
449 inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
450 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
451 if (S == 0)
452 S = Owner.ProvideP;
453 }
454};
455 /*}}}*/
456// Release file /*{{{*/
457 class APT_PUBLIC pkgCache::RlsFileIterator : public Iterator<ReleaseFile, RlsFileIterator> {
458 public:
459 inline ReleaseFile* OwnerPointer() const {
460 return (Owner != 0) ? Owner->RlsFileP : 0;
461 }
462
463 // Iteration
464 inline RlsFileIterator& operator++() {if (S != Owner->RlsFileP) S = Owner->RlsFileP + S->NextFile;return *this;}
465 inline RlsFileIterator operator++(int) { RlsFileIterator const tmp(*this); operator++(); return tmp; }
466
467 // Accessors
468 inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
469 inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;}
470 inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;}
471 inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;}
472 inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;}
473 inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;}
474 inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;}
475 inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return (S->Flags & flag) == flag; }
476
477 std::string RelStr();
478
479 // Constructors
480 inline RlsFileIterator() : Iterator<ReleaseFile, RlsFileIterator>() {}
481 explicit inline RlsFileIterator(pkgCache &Owner) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Owner.RlsFileP) {}
482 inline RlsFileIterator(pkgCache &Owner,ReleaseFile *Trg) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Trg) {}
483};
484 /*}}}*/
485// Package file /*{{{*/
486 class APT_PUBLIC pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> {
487 public:
488 inline PackageFile* OwnerPointer() const {
489 return (Owner != 0) ? Owner->PkgFileP : 0;
490 }
491
492 // Iteration
493 inline PkgFileIterator& operator++() {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile; return *this;}
494 inline PkgFileIterator operator++(int) { PkgFileIterator const tmp(*this); operator++(); return tmp; }
495
496 // Accessors
497 inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
498 inline pkgCache::RlsFileIterator ReleaseFile() const {return RlsFileIterator(*Owner, Owner->RlsFileP + S->Release);}
499 inline const char *Archive() const {return S->Release == 0 ? Component() : ReleaseFile().Archive();}
500 inline const char *Version() const {return S->Release == 0 ? NULL : ReleaseFile().Version();}
501 inline const char *Origin() const {return S->Release == 0 ? NULL : ReleaseFile().Origin();}
502 inline const char *Codename() const {return S->Release == 0 ? NULL : ReleaseFile().Codename();}
503 inline const char *Label() const {return S->Release == 0 ? NULL : ReleaseFile().Label();}
504 inline const char *Site() const {return S->Release == 0 ? NULL : ReleaseFile().Site();}
505 inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return S->Release== 0 ? false : ReleaseFile().Flagged(flag);}
506 inline bool Flagged(pkgCache::Flag::PkgFFlags const flag) const {return (S->Flags & flag) == flag;}
507 inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;}
508 inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}
509 inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}
510
511 std::string RelStr();
512
513 // Constructors
514 inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {}
515 explicit inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
516 inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
517};
518 /*}}}*/
519// Version File /*{{{*/
520 class APT_PUBLIC pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIterator> {
521 public:
522 inline VerFile* OwnerPointer() const {
523 return (Owner != 0) ? Owner->VerFileP : 0;
524 }
525
526 // Iteration
527 inline VerFileIterator& operator++() {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile; return *this;}
528 inline VerFileIterator operator++(int) { VerFileIterator const tmp(*this); operator++(); return tmp; }
529
530 // Accessors
531 inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
532
533 inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}
534 inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
535};
536 /*}}}*/
537// Description File /*{{{*/
538 class APT_PUBLIC pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
539 public:
540 inline DescFile* OwnerPointer() const {
541 return (Owner != 0) ? Owner->DescFileP : 0;
542 }
543
544 // Iteration
545 inline DescFileIterator& operator++() {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile; return *this;}
546 inline DescFileIterator operator++(int) { DescFileIterator const tmp(*this); operator++(); return tmp; }
547
548 // Accessors
549 inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
550
551 inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {}
552 inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
553};
554 /*}}}*/
555// Inlined Begin functions can't be in the class because of order problems /*{{{*/
556 inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
557 {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}
558 inline pkgCache::VerIterator pkgCache::GrpIterator::VersionsInSource() const
559 {
560 return VerIterator(*Owner, Owner->VerP + S->VersionsInSource);
561 }
562 inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
563 {return VerIterator(*Owner,Owner->VerP + S->VersionList);}
564 inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
565 {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}
566 inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
567 {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}
568 inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
569 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
570 inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
571 {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}
572 inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
573 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
574 inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
575 {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}
576 inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
577 {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
578 inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
579 {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
580 /*}}}*/
581#endif
map_pointer
Definition pkgcache.h:98
pkgCache::DepIterator
Definition cacheiterators.h:327
pkgCache::DescFileIterator
Definition cacheiterators.h:538
pkgCache::DescIterator
Definition cacheiterators.h:301
pkgCache::GrpIterator
Definition cacheiterators.h:106
pkgCache::GrpIterator::FindPreferredPkg
PkgIterator FindPreferredPkg(bool const &PreferNonVirtual=true) const
find the package with the "best" architecture
Definition pkgcache.cc:413
pkgCache::Iterator
Definition cacheiterators.h:47
pkgCache::PkgFileIterator
Definition cacheiterators.h:486
pkgCache::PkgIterator
Definition cacheiterators.h:147
pkgCache::PrvIterator
Definition cacheiterators.h:413
pkgCache::RlsFileIterator
Definition cacheiterators.h:457
pkgCache::SrcVerIterator
Definition cacheiterators.h:194
pkgCache::VerFileIterator
Definition cacheiterators.h:520
pkgCache::VerIterator
Definition cacheiterators.h:218
pkgCache::VerIterator::SimilarVer
bool SimilarVer(const VerIterator &B) const
compares two version and returns if they are similar
Definition cacheiterators.h:241
pkgCache::VerIterator::SourceVerStr
const char * SourceVerStr() const
source version this version comes from Always contains the version string, even if it is the same as ...
Definition cacheiterators.h:256
pkgCache::VerIterator::SourceVersion
SrcVerIterator SourceVersion() const
source version this version comes from Always contains the version string, even if it is the same as ...
Definition cacheiterators.h:250
pkgCache::VerIterator::SourcePkgName
const char * SourcePkgName() const
source package name this version comes from Always contains the name, even if it is the same as the b...
Definition cacheiterators.h:253
pkgCache::DepIterator::DependencyProxy
Definition cacheiterators.h:372
pkgCache::Dep::MultiArchImplicit
@ MultiArchImplicit
Definition pkgcache.h:177
pkgCache::DependencyData
information for a single dependency record
Definition pkgcache.h:764
pkgCache::DependencyData::CompareOp
map_flags_t CompareOp
comparison operator specified on the depends line
Definition pkgcache.h:778
pkgCache::DependencyData::Version
map_stringitem_t Version
string of the version the dependency is applied against
Definition pkgcache.h:766
pkgCache::DependencyData::Package
map_pointer< pkgCache::Package > Package
index of the package this depends applies to
Definition pkgcache.h:771
pkgCache::DependencyData::Type
map_number_t Type
Dependency type - Depends, Recommends, Conflicts, etc.
Definition pkgcache.h:774
pkgCache::Dependency
Definition pkgcache.h:783
pkgCache::DescFile
associates a description with a Translation file
Definition pkgcache.h:615
pkgCache::DescFile::NextFile
map_pointer< DescFile > NextFile
next step in the linked list
Definition pkgcache.h:619
pkgCache::Description
datamember of a linked list of available description for a version
Definition pkgcache.h:733
pkgCache::Description::NextDesc
map_pointer< Description > NextDesc
next translation for this description
Definition pkgcache.h:748
pkgCache::Flag::MultiArchImplicit
@ MultiArchImplicit
Definition pkgcache.h:208
pkgCache::Flag::ReleaseFileFlags
ReleaseFileFlags
Definition pkgcache.h:203
pkgCache::Flag::PkgFFlags
PkgFFlags
Definition pkgcache.h:198
pkgCache::Group
groups architecture depending packages together
Definition pkgcache.h:422
pkgCache::Group::FirstPackage
map_pointer< Package > FirstPackage
Link to the first package which belongs to the group.
Definition pkgcache.h:428
pkgCache::PackageFile
stores information about the files used to generate the cache
Definition pkgcache.h:562
pkgCache::PackageFile::NextFile
map_pointer< PackageFile > NextFile
Link to the next PackageFile in the Cache.
Definition pkgcache.h:589
pkgCache::Package
contains information for a single unique package
Definition pkgcache.h:460
pkgCache::Provides
handles virtual packages
Definition pkgcache.h:806
pkgCache::ReleaseFile
stores information about the release files used to generate the cache
Definition pkgcache.h:518
pkgCache::ReleaseFile::NextFile
map_pointer< ReleaseFile > NextFile
Link to the next ReleaseFile in the Cache.
Definition pkgcache.h:547
pkgCache::SourceVersion
information for a single version of a source package
Definition pkgcache.h:631
pkgCache::VerFile
associates a version with a PackageFile
Definition pkgcache.h:603
pkgCache::VerFile::NextFile
map_pointer< VerFile > NextFile
next step in the linked list
Definition pkgcache.h:607
pkgCache::Version
information for a single version of a package
Definition pkgcache.h:652
pkgCache::Version::NextVer
map_pointer< Version > NextVer
next (lower or equal) version in the linked list
Definition pkgcache.h:688
pkgCache::Version::All
@ All
Definition pkgcache.h:667