apt: apt-pkg/cacheiterators.h Source File

apt 2.7.10 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 <apt-pkg/string_view.h>
41
42#include <string.h>
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) */
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(APT::StringView Arch = APT::StringView("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 //Nice printable representation
181 APT_DEPRECATED_MSG("Use APT::PrettyPkg instead") 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// Version Iterator /*{{{*/
193class APT_PUBLIC pkgCache::VerIterator : public Iterator<Version, VerIterator> {
194 public:
195 inline Version* OwnerPointer() const {
196 return (Owner != 0) ? Owner->VerP : 0;
197 }
198
199 // Iteration
200 inline VerIterator& operator++() {if (S != Owner->VerP) S = Owner->VerP + S->NextVer; return *this;}
201 inline VerIterator operator++(int) { VerIterator const tmp(*this); operator++(); return tmp; }
202
203 inline VerIterator NextInSource()
204 {
205 if (S != Owner->VerP)
206 S = Owner->VerP + S->NextInSource;
207 return *this;
208 }
209
210 // Comparison
211 int CompareVer(const VerIterator &B) const;
216 inline bool SimilarVer(const VerIterator &B) const {
217 return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
218 }
219
220 // Accessors
221 inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}
222 inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
225 inline const char *SourcePkgName() const {return Owner->StrP + S->SourcePkgName;}
228 inline const char *SourceVerStr() const {return Owner->StrP + S->SourceVerStr;}
229 inline const char *Arch() const {
230 if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All)
231 return "all";
232 return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
233 }
234 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
235
236 inline DescIterator DescriptionList() const;
237 DescIterator TranslatedDescriptionForLanguage(APT::StringView lang) const;
238 DescIterator TranslatedDescription() const;
239 inline DepIterator DependsList() const;
240 inline PrvIterator ProvidesList() const;
241 inline VerFileIterator FileList() const;
242 bool Downloadable() const;
243 inline const char *PriorityType() const {return Owner->Priority(S->Priority);}
244 const char *MultiArchType() const APT_PURE;
245 std::string RelStr() const;
246
247 bool Automatic() const;
248 VerFileIterator NewestFile() const;
249
250#ifdef APT_COMPILING_APT
251 inline unsigned int PhasedUpdatePercentage() const
252 {
253 return (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage;
254 }
255 inline bool PhasedUpdatePercentage(unsigned int percentage)
256 {
257 if (percentage > 100)
258 return false;
259 (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage = static_cast<uint8_t>(percentage);
260 return true;
261 }
262#endif
263
264 inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
265 if (S == 0)
266 S = OwnerPointer();
267 }
268 inline VerIterator() : Iterator<Version, VerIterator>() {}
269};
270 /*}}}*/
271// Description Iterator /*{{{*/
272class APT_PUBLIC pkgCache::DescIterator : public Iterator<Description, DescIterator> {
273 public:
274 inline Description* OwnerPointer() const {
275 return (Owner != 0) ? Owner->DescP : 0;
276 }
277
278 // Iteration
279 inline DescIterator& operator++() {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc; return *this;}
280 inline DescIterator operator++(int) { DescIterator const tmp(*this); operator++(); return tmp; }
281
282 // Comparison
283 int CompareDesc(const DescIterator &B) const;
284
285 // Accessors
286 inline const char *LanguageCode() const {return Owner->StrP + S->language_code;}
287 inline const char *md5() const {return Owner->StrP + S->md5sum;}
288 inline DescFileIterator FileList() const;
289
290 inline DescIterator() : Iterator<Description, DescIterator>() {}
291 inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
292 if (S == 0)
293 S = Owner.DescP;
294 }
295};
296 /*}}}*/
297// Dependency iterator /*{{{*/
298class APT_PUBLIC pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
299 enum {DepVer, DepRev} Type;
300 DependencyData * S2;
301
302 public:
303 inline Dependency* OwnerPointer() const {
304 return (Owner != 0) ? Owner->DepP : 0;
305 }
306
307 // Iteration
308 DepIterator& operator++();
309 inline DepIterator operator++(int) { DepIterator const tmp(*this); operator++(); return tmp; }
310
311 // Accessors
312 inline const char *TargetVer() const {return S2->Version == 0?0:Owner->StrP + S2->Version;}
313 inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S2->Package);}
314 inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}
315 inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
316 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->ParentVer)].ParentPkg);}
317 inline bool Reverse() const {return Type == DepRev;}
318 bool IsCritical() const APT_PURE;
319 bool IsNegative() const APT_PURE;
320 bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
321 bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
322 /* MultiArch can be translated to SingleArch for an resolver and we did so,
323 by adding dependencies to help the resolver understand the problem, but
324 sometimes it is needed to identify these to ignore them… */
325 inline bool IsMultiArchImplicit() const APT_PURE {
326 return (S2->CompareOp & pkgCache::Dep::MultiArchImplicit) == pkgCache::Dep::MultiArchImplicit;
327 }
328 /* This covers additionally negative dependencies, which aren't arch-specific,
329 but change architecture nonetheless as a Conflicts: foo does applies for all archs */
330 bool IsImplicit() const APT_PURE;
331
332 bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
333 bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
334 void GlobOr(DepIterator &Start,DepIterator &End);
335 Version **AllTargets() const;
336 bool SmartTargetPkg(PkgIterator &Result) const;
337 inline const char *CompType() const {return Owner->CompType(S2->CompareOp);}
338 inline const char *DepType() const {return Owner->DepType(S2->Type);}
339
340 // overrides because we are special
341 struct DependencyProxy
342 {
343 map_stringitem_t &Version;
344 map_pointer<pkgCache::Package> &Package;
345 map_id_t &ID;
346 unsigned char &Type;
347 unsigned char &CompareOp;
348 map_pointer<pkgCache::Version> &ParentVer;
349 map_pointer<pkgCache::DependencyData> &DependencyData;
350 map_pointer<Dependency> &NextRevDepends;
351 map_pointer<Dependency> &NextDepends;
352 map_pointer<pkgCache::DependencyData> &NextData;
353 DependencyProxy const * operator->() const { return this; }
354 DependencyProxy * operator->() { return this; }
355 };
356 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 };}
357 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 };}
358 void ReMap(void const * const oldMap, void * const newMap)
359 {
360 Iterator<Dependency, DepIterator>::ReMap(oldMap, newMap);
361 if (Owner == 0 || S == 0 || S2 == 0)
362 return;
363 S2 = static_cast<DependencyData *>(newMap) + (S2 - static_cast<DependencyData const *>(oldMap));
364 }
365
366 //Nice printable representation
367 APT_DEPRECATED_MSG("Use APT::PrettyDep instead") friend std::ostream& operator <<(std::ostream& out, DepIterator D);
368
369 inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
370 Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
371 if (S == 0)
372 S = Owner.DepP;
373 }
374 inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
375 Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
376 if (S == 0)
377 S = Owner.DepP;
378 }
379 inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer), S2(0) {}
380};
381 /*}}}*/
382// Provides iterator /*{{{*/
383class APT_PUBLIC pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
384 enum {PrvVer, PrvPkg} Type;
385
386 public:
387 inline Provides* OwnerPointer() const {
388 return (Owner != 0) ? Owner->ProvideP : 0;
389 }
390
391 // Iteration
392 inline PrvIterator& operator ++() {if (S != Owner->ProvideP) S = Owner->ProvideP +
393 (Type == PrvVer?S->NextPkgProv:S->NextProvides); return *this;}
394 inline PrvIterator operator++(int) { PrvIterator const tmp(*this); operator++(); return tmp; }
395
396 // Accessors
397 inline const char *Name() const {return ParentPkg().Name();}
398 inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
399 inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
400 inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}
401 inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->Version)].ParentPkg);}
402
403 /* MultiArch can be translated to SingleArch for an resolver and we did so,
404 by adding provides to help the resolver understand the problem, but
405 sometimes it is needed to identify these to ignore them… */
406 bool IsMultiArchImplicit() const APT_PURE
407 { return (S->Flags & pkgCache::Flag::MultiArchImplicit) == pkgCache::Flag::MultiArchImplicit; }
408
409
410 inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
411 inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
412 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
413 if (S == 0)
414 S = Owner.ProvideP;
415 }
416 inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
417 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
418 if (S == 0)
419 S = Owner.ProvideP;
420 }
421};
422 /*}}}*/
423// Release file /*{{{*/
424class APT_PUBLIC pkgCache::RlsFileIterator : public Iterator<ReleaseFile, RlsFileIterator> {
425 public:
426 inline ReleaseFile* OwnerPointer() const {
427 return (Owner != 0) ? Owner->RlsFileP : 0;
428 }
429
430 // Iteration
431 inline RlsFileIterator& operator++() {if (S != Owner->RlsFileP) S = Owner->RlsFileP + S->NextFile;return *this;}
432 inline RlsFileIterator operator++(int) { RlsFileIterator const tmp(*this); operator++(); return tmp; }
433
434 // Accessors
435 inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
436 inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;}
437 inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;}
438 inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;}
439 inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;}
440 inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;}
441 inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;}
442 inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return (S->Flags & flag) == flag; }
443
444 std::string RelStr();
445
446 // Constructors
447 inline RlsFileIterator() : Iterator<ReleaseFile, RlsFileIterator>() {}
448 explicit inline RlsFileIterator(pkgCache &Owner) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Owner.RlsFileP) {}
449 inline RlsFileIterator(pkgCache &Owner,ReleaseFile *Trg) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Trg) {}
450};
451 /*}}}*/
452// Package file /*{{{*/
453class APT_PUBLIC pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> {
454 public:
455 inline PackageFile* OwnerPointer() const {
456 return (Owner != 0) ? Owner->PkgFileP : 0;
457 }
458
459 // Iteration
460 inline PkgFileIterator& operator++() {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile; return *this;}
461 inline PkgFileIterator operator++(int) { PkgFileIterator const tmp(*this); operator++(); return tmp; }
462
463 // Accessors
464 inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
465 inline pkgCache::RlsFileIterator ReleaseFile() const {return RlsFileIterator(*Owner, Owner->RlsFileP + S->Release);}
466 inline const char *Archive() const {return S->Release == 0 ? Component() : ReleaseFile().Archive();}
467 inline const char *Version() const {return S->Release == 0 ? NULL : ReleaseFile().Version();}
468 inline const char *Origin() const {return S->Release == 0 ? NULL : ReleaseFile().Origin();}
469 inline const char *Codename() const {return S->Release == 0 ? NULL : ReleaseFile().Codename();}
470 inline const char *Label() const {return S->Release == 0 ? NULL : ReleaseFile().Label();}
471 inline const char *Site() const {return S->Release == 0 ? NULL : ReleaseFile().Site();}
472 inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return S->Release== 0 ? false : ReleaseFile().Flagged(flag);}
473 inline bool Flagged(pkgCache::Flag::PkgFFlags const flag) const {return (S->Flags & flag) == flag;}
474 inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;}
475 inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}
476 inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}
477
478 std::string RelStr();
479
480 // Constructors
481 inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {}
482 explicit inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
483 inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
484};
485 /*}}}*/
486// Version File /*{{{*/
487class APT_PUBLIC pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIterator> {
488 public:
489 inline VerFile* OwnerPointer() const {
490 return (Owner != 0) ? Owner->VerFileP : 0;
491 }
492
493 // Iteration
494 inline VerFileIterator& operator++() {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile; return *this;}
495 inline VerFileIterator operator++(int) { VerFileIterator const tmp(*this); operator++(); return tmp; }
496
497 // Accessors
498 inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
499
500 inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}
501 inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
502};
503 /*}}}*/
504// Description File /*{{{*/
505class APT_PUBLIC pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
506 public:
507 inline DescFile* OwnerPointer() const {
508 return (Owner != 0) ? Owner->DescFileP : 0;
509 }
510
511 // Iteration
512 inline DescFileIterator& operator++() {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile; return *this;}
513 inline DescFileIterator operator++(int) { DescFileIterator const tmp(*this); operator++(); return tmp; }
514
515 // Accessors
516 inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
517
518 inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {}
519 inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
520};
521 /*}}}*/
522// Inlined Begin functions can't be in the class because of order problems /*{{{*/
523inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const
524 {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}
525 inline pkgCache::VerIterator pkgCache::GrpIterator::VersionsInSource() const
526 {
527 return VerIterator(*Owner, Owner->VerP + S->VersionsInSource);
528 }
529inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
530 {return VerIterator(*Owner,Owner->VerP + S->VersionList);}
531inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
532 {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}
533inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
534 {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}
535inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
536 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
537inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
538 {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}
539inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
540 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
541inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
542 {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}
543inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
544 {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
545inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
546 {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
547 /*}}}*/
548#endif
APT::StringView
Simple subset of std::string_view from C++17.
Definition string_view.h:27
map_pointer
Definition pkgcache.h:98
pkgCache::Iterator
Definition pkgcache.h:144
pkgCache
Definition cacheiterators.h:47
pkgCache::SimilarVer
bool SimilarVer(const VerIterator &B) const
compares two version and returns if they are similar
Definition cacheiterators.h:216
pkgCache::FindPreferredPkg
PkgIterator FindPreferredPkg(bool const &PreferNonVirtual=true) const
find the package with the "best" architecture
pkgCache::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:228
pkgCache::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:225
pkgCache::Dep::MultiArchImplicit
@ MultiArchImplicit
Definition pkgcache.h:175
pkgCache::DependencyData
information for a single dependency record
Definition pkgcache.h:738
pkgCache::DependencyProxy
Definition cacheiterators.h:342
pkgCache::Flag::MultiArchImplicit
@ MultiArchImplicit
Definition pkgcache.h:206
pkgCache::Flag::ReleaseFileFlags
ReleaseFileFlags
Definition pkgcache.h:201
pkgCache::Flag::PkgFFlags
PkgFFlags
Definition pkgcache.h:196
pkgCache::Group
groups architecture depending packages together
Definition pkgcache.h:415
pkgCache::Package
contains information for a single unique package
Definition pkgcache.h:450
pkgCache::Version
information for a single version of a package
Definition pkgcache.h:625
pkgCache::Version::All
@ All
Definition pkgcache.h:641