apt 3.0.3
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 */
47template<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) */
106class 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 /*{{{*/
147class 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 /*{{{*/
193class 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 /*{{{*/
218class 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 /*{{{*/
301class 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 /*{{{*/
327class 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 {
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
372 {
375 map_id_t &ID;
376 unsigned char &Type;
377 unsigned char &CompareOp;
380 map_pointer<Dependency> &NextRevDepends;
381 map_pointer<Dependency> &NextDepends;
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 /*{{{*/
413class 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 ++() {if (S != Owner->ProvideP) S = Owner->ProvideP +
423 (Type == PrvVer?S->NextPkgProv:S->NextProvides); return *this;}
424 inline PrvIterator operator++(int) { PrvIterator const tmp(*this); operator++(); return tmp; }
425
426 // Accessors
427 inline const char *Name() const {return ParentPkg().Name();}
428 inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
429 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
430 inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}
431 inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->Version)].ParentPkg);}
432
433 /* MultiArch can be translated to SingleArch for an resolver and we did so,
434 by adding provides to help the resolver understand the problem, but
435 sometimes it is needed to identify these to ignore them… */
436 bool IsMultiArchImplicit() const APT_PURE
438
439
440 inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
441 inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
442 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
443 if (S == 0)
444 S = Owner.ProvideP;
445 }
446 inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
447 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
448 if (S == 0)
449 S = Owner.ProvideP;
450 }
451};
452 /*}}}*/
453// Release file /*{{{*/
454class APT_PUBLIC pkgCache::RlsFileIterator : public Iterator<ReleaseFile, RlsFileIterator> {
455 public:
456 inline ReleaseFile* OwnerPointer() const {
457 return (Owner != 0) ? Owner->RlsFileP : 0;
458 }
459
460 // Iteration
461 inline RlsFileIterator& operator++() {if (S != Owner->RlsFileP) S = Owner->RlsFileP + S->NextFile;return *this;}
462 inline RlsFileIterator operator++(int) { RlsFileIterator const tmp(*this); operator++(); return tmp; }
463
464 // Accessors
465 inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
466 inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;}
467 inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;}
468 inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;}
469 inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;}
470 inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;}
471 inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;}
472 inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return (S->Flags & flag) == flag; }
473
474 std::string RelStr();
475
476 // Constructors
477 inline RlsFileIterator() : Iterator<ReleaseFile, RlsFileIterator>() {}
478 explicit inline RlsFileIterator(pkgCache &Owner) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Owner.RlsFileP) {}
479 inline RlsFileIterator(pkgCache &Owner,ReleaseFile *Trg) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Trg) {}
480};
481 /*}}}*/
482// Package file /*{{{*/
483class APT_PUBLIC pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> {
484 public:
485 inline PackageFile* OwnerPointer() const {
486 return (Owner != 0) ? Owner->PkgFileP : 0;
487 }
488
489 // Iteration
490 inline PkgFileIterator& operator++() {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile; return *this;}
491 inline PkgFileIterator operator++(int) { PkgFileIterator const tmp(*this); operator++(); return tmp; }
492
493 // Accessors
494 inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
495 inline pkgCache::RlsFileIterator ReleaseFile() const {return RlsFileIterator(*Owner, Owner->RlsFileP + S->Release);}
496 inline const char *Archive() const {return S->Release == 0 ? Component() : ReleaseFile().Archive();}
497 inline const char *Version() const {return S->Release == 0 ? NULL : ReleaseFile().Version();}
498 inline const char *Origin() const {return S->Release == 0 ? NULL : ReleaseFile().Origin();}
499 inline const char *Codename() const {return S->Release == 0 ? NULL : ReleaseFile().Codename();}
500 inline const char *Label() const {return S->Release == 0 ? NULL : ReleaseFile().Label();}
501 inline const char *Site() const {return S->Release == 0 ? NULL : ReleaseFile().Site();}
502 inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return S->Release== 0 ? false : ReleaseFile().Flagged(flag);}
503 inline bool Flagged(pkgCache::Flag::PkgFFlags const flag) const {return (S->Flags & flag) == flag;}
504 inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;}
505 inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}
506 inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}
507
508 std::string RelStr();
509
510 // Constructors
511 inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {}
512 explicit inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
513 inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
514};
515 /*}}}*/
516// Version File /*{{{*/
517class APT_PUBLIC pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIterator> {
518 public:
519 inline VerFile* OwnerPointer() const {
520 return (Owner != 0) ? Owner->VerFileP : 0;
521 }
522
523 // Iteration
524 inline VerFileIterator& operator++() {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile; return *this;}
525 inline VerFileIterator operator++(int) { VerFileIterator const tmp(*this); operator++(); return tmp; }
526
527 // Accessors
528 inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
529
530 inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}
531 inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
532};
533 /*}}}*/
534// Description File /*{{{*/
535class APT_PUBLIC pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
536 public:
537 inline DescFile* OwnerPointer() const {
538 return (Owner != 0) ? Owner->DescFileP : 0;
539 }
540
541 // Iteration
542 inline DescFileIterator& operator++() {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile; return *this;}
543 inline DescFileIterator operator++(int) { DescFileIterator const tmp(*this); operator++(); return tmp; }
544
545 // Accessors
546 inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
547
548 inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {}
549 inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
550};
551 /*}}}*/
552// Inlined Begin functions can't be in the class because of order problems /*{{{*/
553inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
554 {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}
555 inline pkgCache::VerIterator pkgCache::GrpIterator::VersionsInSource() const
556 {
557 return VerIterator(*Owner, Owner->VerP + S->VersionsInSource);
558 }
559inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
560 {return VerIterator(*Owner,Owner->VerP + S->VersionList);}
561inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
562 {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}
563inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
564 {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}
565inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
566 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
567inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
568 {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}
569inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
570 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
571inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
572 {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}
573inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
574 {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
575inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
576 {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
577 /*}}}*/
578#endif
Definition pkgcache.h:98
Definition pkgcache.h:145
Definition cacheiterators.h:47
bool SimilarVer(const VerIterator &B) const
compares two version and returns if they are similar
Definition cacheiterators.h:241
PkgIterator FindPreferredPkg(bool const &PreferNonVirtual=true) const
find the package with the "best" architecture
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
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
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
@ MultiArchImplicit
Definition pkgcache.h:177
information for a single dependency record
Definition pkgcache.h:764
Definition cacheiterators.h:372
@ MultiArchImplicit
Definition pkgcache.h:208
ReleaseFileFlags
Definition pkgcache.h:203
PkgFFlags
Definition pkgcache.h:198
groups architecture depending packages together
Definition pkgcache.h:422
contains information for a single unique package
Definition pkgcache.h:460
information for a single version of a source package
Definition pkgcache.h:631
map_stringitem_t VerStr
complete version string
Definition pkgcache.h:637
map_pointer< pkgCache::Group > Group
Group the source package belongs too.
Definition pkgcache.h:635
information for a single version of a package
Definition pkgcache.h:652
@ All
Definition pkgcache.h:667