apt 3.2.0 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 constexpr Str* OwnerPointer() const noexcept { 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 constexpr bool end() const noexcept {return Owner == 0 || S == OwnerPointer();}
71
72 // Comparison
73 constexpr bool operator ==(const Itr &B) const noexcept {return S == B.S;}
74 constexpr bool operator !=(const Itr &B) const noexcept {return S != B.S;}
75
76 // Accessors
77 constexpr Str *operator ->() noexcept {return S;}
78 constexpr Str const *operator ->() const noexcept {return S;}
79 constexpr operator Str *() noexcept {return S == OwnerPointer() ? 0 : S;}
80 constexpr operator Str const *() const noexcept {return S == OwnerPointer() ? 0 : S;}
81 constexpr Str &operator *() noexcept {return *S;}
82 constexpr Str const &operator *() const noexcept {return *S;}
83 constexpr pkgCache *Cache() const noexcept {return Owner;}
84
85 // Mixed stuff
86 constexpr bool IsGood() const noexcept { return S && Owner && ! end();}
87 constexpr unsigned long Index() const noexcept {return S - OwnerPointer();}
88 constexpr map_pointer<Str> MapPointer() const noexcept {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 constexpr Iterator() noexcept : S(0), Owner(0) {}
98 constexpr Iterator(pkgCache &Owner,Str *T = 0) noexcept : 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 constexpr Group* OwnerPointer() const noexcept {
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) noexcept : 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 constexpr const char *Name() const noexcept {return S->Name == 0?0:Owner->StrP + S->Name;}
124 constexpr PkgIterator PackageList() const noexcept;
125 constexpr VerIterator VersionsInSource() const noexcept;
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 constexpr GrpIterator(pkgCache &Owner, Group *Trg) noexcept : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
139 if (S == 0)
140 S = OwnerPointer();
141 }
142 constexpr GrpIterator() noexcept : 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 noexcept {
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) noexcept : 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 constexpr const char *Name() const noexcept { return Group().Name(); }
168 constexpr bool Purge() const noexcept {return S->CurrentState == pkgCache::State::Purge ||
169 (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
170 constexpr const char *Arch() const noexcept {return S->Arch == 0?0:Owner->StrP + S->Arch;}
171 constexpr APT_PURE GrpIterator Group() const noexcept { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
172
173 constexpr VerIterator VersionList() const noexcept APT_PURE;
174 constexpr VerIterator CurrentVer() const noexcept APT_PURE;
175 constexpr DepIterator RevDependsList() const noexcept APT_PURE;
176 constexpr PrvIterator ProvidesList() const noexcept 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 constexpr PkgIterator(pkgCache &Owner,Package *Trg) noexcept : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
186 if (S == 0)
187 S = OwnerPointer();
188 }
189 constexpr PkgIterator() noexcept : Iterator<Package, PkgIterator>(), HashIndex(0) {}
190};
191 /*}}}*/
192// SourceVersion Iterator /*{{{*/
193 class APT_PUBLIC pkgCache::SrcVerIterator : public Iterator<SourceVersion, SrcVerIterator>
194{
195 public:
196 constexpr SourceVersion *OwnerPointer() const noexcept
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 constexpr APT_PURE GrpIterator Group() const noexcept { return GrpIterator(*Owner, Owner->GrpP + S->Group); }
206 constexpr const char *VerStr() const noexcept { return S->VerStr == 0 ? 0 : Owner->StrP + S->VerStr; }
207
208 constexpr SrcVerIterator(pkgCache &Owner, SourceVersion *Trg = 0) noexcept : Iterator<SourceVersion, SrcVerIterator>(Owner, Trg)
209 {
210 if (S == 0)
211 S = OwnerPointer();
212 }
213 constexpr SrcVerIterator() noexcept : 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 noexcept {
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 constexpr VerIterator NextInSource() noexcept
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 constexpr bool SimilarVer(const VerIterator &B) const noexcept {
242 return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
243 }
244
245 // Accessors
246 constexpr const char *VerStr() const noexcept {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}
247 constexpr const char *Section() const noexcept {return S->Section == 0?0:Owner->StrP + S->Section;}
250 constexpr SrcVerIterator SourceVersion() const noexcept { return SrcVerIterator(*Owner, Owner->SrcVerP + S->SourceVersion); }
253 constexpr const char *SourcePkgName() const noexcept { return SourceVersion().Group().Name(); }
256 constexpr const char *SourceVerStr() const noexcept { return SourceVersion().VerStr(); }
257 constexpr const char *Arch() const noexcept {
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 constexpr PkgIterator ParentPkg() const noexcept {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
263
264 constexpr DescIterator DescriptionList() const noexcept;
265 DescIterator TranslatedDescriptionForLanguage(std::string_view lang) const;
266 DescIterator TranslatedDescription() const;
267 constexpr DepIterator DependsList() const noexcept;
268 constexpr PrvIterator ProvidesList() const noexcept;
269 constexpr VerFileIterator FileList() const noexcept;
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 void ArchVariant(map_stringitem_t variant) const
285 {
286 (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->ArchVariant = variant;
287 }
288 inline std::string_view ArchVariant() const
289 {
290 if (auto I = (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->ArchVariant)
291 return Owner->ViewString(I);
292 return {};
293 }
294 inline bool PhasedUpdatePercentage(unsigned int percentage)
295 {
296 if (percentage > 100)
297 return false;
298 (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage = static_cast<uint8_t>(percentage);
299 return true;
300 }
301#endif
302
303 constexpr VerIterator(pkgCache &Owner,Version *Trg = 0) noexcept : Iterator<Version, VerIterator>(Owner, Trg) {
304 if (S == 0)
305 S = OwnerPointer();
306 }
307 constexpr VerIterator() noexcept : Iterator<Version, VerIterator>() {}
308};
309 /*}}}*/
310// Description Iterator /*{{{*/
311 class APT_PUBLIC pkgCache::DescIterator : public Iterator<Description, DescIterator> {
312 public:
313 constexpr Description* OwnerPointer() const noexcept {
314 return (Owner != 0) ? Owner->DescP : 0;
315 }
316
317 // Iteration
318 inline DescIterator& operator++() {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc; return *this;}
319 inline DescIterator operator++(int) { DescIterator const tmp(*this); operator++(); return tmp; }
320
321 // Comparison
322 int CompareDesc(const DescIterator &B) const;
323
324 // Accessors
325 constexpr const char *LanguageCode() const noexcept {return Owner->StrP + S->language_code;}
326 constexpr const char *md5() const noexcept {return Owner->StrP + S->md5sum;}
327 constexpr DescFileIterator FileList() const noexcept;
328
329 constexpr DescIterator() noexcept : Iterator<Description, DescIterator>() {}
330 constexpr DescIterator(pkgCache &Owner,Description *Trg = 0) noexcept : Iterator<Description, DescIterator>(Owner, Trg) {
331 if (S == 0)
332 S = Owner.DescP;
333 }
334};
335 /*}}}*/
336// Dependency iterator /*{{{*/
337 class APT_PUBLIC pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
338 enum {DepVer, DepRev} Type;
339 DependencyData * S2;
340
341 public:
342 constexpr Dependency* OwnerPointer() const noexcept {
343 return (Owner != 0) ? Owner->DepP : 0;
344 }
345
346 // Iteration
347 DepIterator& operator++();
348 inline DepIterator operator++(int) { DepIterator const tmp(*this); operator++(); return tmp; }
349
350 // Accessors
351 constexpr const char *TargetVer() const noexcept {return S2->Version == 0?0:Owner->StrP + S2->Version;}
352 constexpr PkgIterator TargetPkg() const noexcept {return PkgIterator(*Owner,Owner->PkgP + S2->Package);}
353 inline PkgIterator SmartTargetPkg() const noexcept {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}
354 constexpr VerIterator ParentVer() const noexcept {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
355 constexpr PkgIterator ParentPkg() const noexcept {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->ParentVer)].ParentPkg);}
356 constexpr bool Reverse() const noexcept {return Type == DepRev;}
357 bool IsCritical() const APT_PURE;
358 bool IsNegative() const APT_PURE;
359 bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
360 bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
361 /* MultiArch can be translated to SingleArch for an resolver and we did so,
362 by adding dependencies to help the resolver understand the problem, but
363 sometimes it is needed to identify these to ignore them… */
364 constexpr bool IsMultiArchImplicit() const APT_PURE {
365 return (S2->CompareOp & pkgCache::Dep::MultiArchImplicit) == pkgCache::Dep::MultiArchImplicit;
366 }
367 /* This covers additionally negative dependencies, which aren't arch-specific,
368 but change architecture nonetheless as a Conflicts: foo does applies for all archs */
369 bool IsImplicit() const APT_PURE;
370
371 bool IsSatisfied(PkgIterator const &Pkg) const APT_PURE;
372 bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
373 bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
374 void GlobOr(DepIterator &Start,DepIterator &End);
375 Version **AllTargets() const;
376 bool SmartTargetPkg(PkgIterator &Result) const;
377 inline const char *CompType() const {return Owner->CompType(S2->CompareOp);}
378 inline const char *DepType() const {return Owner->DepType(S2->Type);}
379
380 // overrides because we are special
381 struct DependencyProxy
382 {
383 map_stringitem_t &Version;
384 map_pointer<pkgCache::Package> &Package;
385 map_id_t &ID;
386 unsigned char &Type;
387 unsigned char &CompareOp;
388 map_pointer<pkgCache::Version> &ParentVer;
389 map_pointer<pkgCache::DependencyData> &DependencyData;
390 map_pointer<Dependency> &NextRevDepends;
391 map_pointer<Dependency> &NextDepends;
392 map_pointer<pkgCache::DependencyData> &NextData;
393 constexpr DependencyProxy const * operator->() const noexcept { return this; }
394 constexpr DependencyProxy * operator->() noexcept { return this; }
395 };
396 constexpr DependencyProxy operator->() const noexcept {return (DependencyProxy) { S2->Version, S2->Package, S->ID, S2->Type, S2->CompareOp, S->ParentVer, S->DependencyData, S->NextRevDepends, S->NextDepends, S2->NextData };}
397 constexpr DependencyProxy operator->() {return (DependencyProxy) { S2->Version, S2->Package, S->ID, S2->Type, S2->CompareOp, S->ParentVer, S->DependencyData, S->NextRevDepends, S->NextDepends, S2->NextData };}
398 void ReMap(void const * const oldMap, void * const newMap)
399 {
400 Iterator<Dependency, DepIterator>::ReMap(oldMap, newMap);
401 if (Owner == 0 || S == 0 || S2 == 0)
402 return;
403 S2 = static_cast<DependencyData *>(newMap) + (S2 - static_cast<DependencyData const *>(oldMap));
404 }
405
406 // for a nice printable representation you likely want APT::PrettyDep instead
407 friend std::ostream& operator<<(std::ostream& out, DepIterator D);
408
409 constexpr DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) noexcept :
410 Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
411 if (S == 0)
412 S = Owner.DepP;
413 }
414 constexpr DepIterator(pkgCache &Owner, Dependency *Trg, Package*) noexcept :
415 Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
416 if (S == 0)
417 S = Owner.DepP;
418 }
419 constexpr DepIterator() noexcept : Iterator<Dependency, DepIterator>(), Type(DepVer), S2(0) {}
420};
421 /*}}}*/
422// Provides iterator /*{{{*/
423 class APT_PUBLIC pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
424 enum {PrvVer, PrvPkg} Type;
425
426 public:
427 constexpr Provides* OwnerPointer() const noexcept {
428 return (Owner != 0) ? Owner->ProvideP : 0;
429 }
430
431 // Iteration
432 inline PrvIterator& operator ++() {
433 if (S != Owner->ProvideP)
434 S = Owner->ProvideP + (Type == PrvVer ? S->NextPkgProv : S->NextProvides);
435 return *this;
436 }
437 inline PrvIterator operator++(int) { PrvIterator const tmp(*this); operator++(); return tmp; }
438
439 // Accessors
440 constexpr const char *Name() const noexcept {return ParentPkg().Name();}
441 constexpr const char *ProvideVersion() const noexcept {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
442 constexpr PkgIterator ParentPkg() const noexcept {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
443 constexpr VerIterator OwnerVer() const noexcept {return VerIterator(*Owner,Owner->VerP + S->Version);}
444 constexpr PkgIterator OwnerPkg() const noexcept {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->Version)].ParentPkg);}
445
446 /* MultiArch can be translated to SingleArch for an resolver and we did so,
447 by adding provides to help the resolver understand the problem, but
448 sometimes it is needed to identify these to ignore them… */
449 bool IsMultiArchImplicit() const APT_PURE
450 { return (S->Flags & pkgCache::Flag::MultiArchImplicit) == pkgCache::Flag::MultiArchImplicit; }
451
452
453 constexpr PrvIterator() noexcept : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
454 constexpr PrvIterator(pkgCache &Owner, Provides *Trg, Version*) noexcept :
455 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
456 if (S == 0)
457 S = Owner.ProvideP;
458 }
459 constexpr PrvIterator(pkgCache &Owner, Provides *Trg, Package*) noexcept :
460 Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
461 if (S == 0)
462 S = Owner.ProvideP;
463 }
464};
465 /*}}}*/
466// Release file /*{{{*/
467 class APT_PUBLIC pkgCache::RlsFileIterator : public Iterator<ReleaseFile, RlsFileIterator> {
468 public:
469 constexpr ReleaseFile* OwnerPointer() const noexcept {
470 return (Owner != 0) ? Owner->RlsFileP : 0;
471 }
472
473 // Iteration
474 inline RlsFileIterator& operator++() {if (S != Owner->RlsFileP) S = Owner->RlsFileP + S->NextFile;return *this;}
475 inline RlsFileIterator operator++(int) { RlsFileIterator const tmp(*this); operator++(); return tmp; }
476
477 // Accessors
478 constexpr const char *FileName() const noexcept {return S->FileName == 0?0:Owner->StrP + S->FileName;}
479 constexpr const char *Archive() const noexcept {return S->Archive == 0?0:Owner->StrP + S->Archive;}
480 constexpr const char *Version() const noexcept {return S->Version == 0?0:Owner->StrP + S->Version;}
481 constexpr const char *Origin() const noexcept {return S->Origin == 0?0:Owner->StrP + S->Origin;}
482 constexpr const char *Codename() const noexcept {return S->Codename ==0?0:Owner->StrP + S->Codename;}
483 constexpr const char *Label() const noexcept {return S->Label == 0?0:Owner->StrP + S->Label;}
484 constexpr const char *Site() const noexcept {return S->Site == 0?0:Owner->StrP + S->Site;}
485 constexpr bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const noexcept {return (S->Flags & flag) == flag; }
486
487 std::string RelStr();
488
489 // Constructors
490 constexpr RlsFileIterator() noexcept : Iterator<ReleaseFile, RlsFileIterator>() {}
491 explicit constexpr RlsFileIterator(pkgCache &Owner) noexcept : Iterator<ReleaseFile, RlsFileIterator>(Owner, Owner.RlsFileP) {}
492 constexpr RlsFileIterator(pkgCache &Owner,ReleaseFile *Trg) noexcept : Iterator<ReleaseFile, RlsFileIterator>(Owner, Trg) {}
493};
494 /*}}}*/
495// Package file /*{{{*/
496 class APT_PUBLIC pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> {
497 public:
498 constexpr PackageFile* OwnerPointer() const noexcept {
499 return (Owner != 0) ? Owner->PkgFileP : 0;
500 }
501
502 // Iteration
503 inline PkgFileIterator& operator++() {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile; return *this;}
504 inline PkgFileIterator operator++(int) { PkgFileIterator const tmp(*this); operator++(); return tmp; }
505
506 // Accessors
507 constexpr const char *FileName() const noexcept {return S->FileName == 0?0:Owner->StrP + S->FileName;}
508 constexpr pkgCache::RlsFileIterator ReleaseFile() const noexcept {return RlsFileIterator(*Owner, Owner->RlsFileP + S->Release);}
509 constexpr const char *Archive() const noexcept {return S->Release == 0 ? Component() : ReleaseFile().Archive();}
510 constexpr const char *Version() const noexcept {return S->Release == 0 ? NULL : ReleaseFile().Version();}
511 constexpr const char *Origin() const noexcept {return S->Release == 0 ? NULL : ReleaseFile().Origin();}
512 constexpr const char *Codename() const noexcept {return S->Release == 0 ? NULL : ReleaseFile().Codename();}
513 constexpr const char *Label() const noexcept {return S->Release == 0 ? NULL : ReleaseFile().Label();}
514 constexpr const char *Site() const noexcept {return S->Release == 0 ? NULL : ReleaseFile().Site();}
515 constexpr bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const noexcept {return S->Release== 0 ? false : ReleaseFile().Flagged(flag);}
516 constexpr bool Flagged(pkgCache::Flag::PkgFFlags const flag) const noexcept {return (S->Flags & flag) == flag;}
517 constexpr const char *Component() const noexcept {return S->Component == 0?0:Owner->StrP + S->Component;}
518 constexpr const char *Architecture() const noexcept {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}
519 constexpr const char *IndexType() const noexcept {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}
520
521 std::string RelStr();
522
523 // Constructors
524 constexpr PkgFileIterator() noexcept : Iterator<PackageFile, PkgFileIterator>() {}
525 explicit constexpr PkgFileIterator(pkgCache &Owner) noexcept : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
526 constexpr PkgFileIterator(pkgCache &Owner,PackageFile *Trg) noexcept : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
527};
528 /*}}}*/
529// Version File /*{{{*/
530 class APT_PUBLIC pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIterator> {
531 public:
532 constexpr VerFile* OwnerPointer() const noexcept {
533 return (Owner != 0) ? Owner->VerFileP : 0;
534 }
535
536 // Iteration
537 inline VerFileIterator& operator++() {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile; return *this;}
538 inline VerFileIterator operator++(int) { VerFileIterator const tmp(*this); operator++(); return tmp; }
539
540 // Accessors
541 constexpr PkgFileIterator File() const noexcept {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
542
543 constexpr VerFileIterator() noexcept : Iterator<VerFile, VerFileIterator>() {}
544 constexpr VerFileIterator(pkgCache &Owner,VerFile *Trg) noexcept : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
545};
546 /*}}}*/
547// Description File /*{{{*/
548 class APT_PUBLIC pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
549 public:
550 constexpr DescFile* OwnerPointer() const noexcept {
551 return (Owner != 0) ? Owner->DescFileP : 0;
552 }
553
554 // Iteration
555 inline DescFileIterator& operator++() {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile; return *this;}
556 inline DescFileIterator operator++(int) { DescFileIterator const tmp(*this); operator++(); return tmp; }
557
558 // Accessors
559 constexpr PkgFileIterator File() const noexcept {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
560
561 constexpr DescFileIterator() noexcept : Iterator<DescFile, DescFileIterator>() {}
562 constexpr DescFileIterator(pkgCache &Owner,DescFile *Trg) noexcept : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
563};
564 /*}}}*/
565// Inlined Begin functions can't be in the class because of order problems /*{{{*/
566 constexpr pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const noexcept
567 {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}
568 constexpr pkgCache::VerIterator pkgCache::GrpIterator::VersionsInSource() const noexcept
569 {
570 return VerIterator(*Owner, Owner->VerP + S->VersionsInSource);
571 }
572 constexpr pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const noexcept
573 {return VerIterator(*Owner,Owner->VerP + S->VersionList);}
574 constexpr pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const noexcept
575 {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}
576 constexpr pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const noexcept
577 {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}
578 constexpr pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const noexcept
579 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
580 constexpr pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const noexcept
581 {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}
582 constexpr pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const noexcept
583 {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
584 constexpr pkgCache::DepIterator pkgCache::VerIterator::DependsList() const noexcept
585 {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}
586 constexpr pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const noexcept
587 {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
588 constexpr pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const noexcept
589 {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
590 /*}}}*/
591#endif
map_pointer
Definition pkgcache.h:98
pkgCache::DepIterator
Definition cacheiterators.h:337
pkgCache::DescFileIterator
Definition cacheiterators.h:548
pkgCache::DescIterator
Definition cacheiterators.h:311
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:424
pkgCache::Iterator
Definition cacheiterators.h:47
pkgCache::PkgFileIterator
Definition cacheiterators.h:496
pkgCache::PkgIterator
Definition cacheiterators.h:147
pkgCache::PrvIterator
Definition cacheiterators.h:423
pkgCache::RlsFileIterator
Definition cacheiterators.h:467
pkgCache::SrcVerIterator
Definition cacheiterators.h:194
pkgCache::VerFileIterator
Definition cacheiterators.h:530
pkgCache::VerIterator
Definition cacheiterators.h:218
pkgCache::VerIterator::SourceVerStr
constexpr const char * SourceVerStr() const noexcept
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
constexpr SrcVerIterator SourceVersion() const noexcept
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
constexpr const char * SourcePkgName() const noexcept
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::VerIterator::SimilarVer
constexpr bool SimilarVer(const VerIterator &B) const noexcept
compares two version and returns if they are similar
Definition cacheiterators.h:241
pkgCache::DepIterator::DependencyProxy
Definition cacheiterators.h:382
pkgCache::Dep::MultiArchImplicit
@ MultiArchImplicit
Definition pkgcache.h:177
pkgCache::DependencyData
information for a single dependency record
Definition pkgcache.h:765
pkgCache::DependencyData::CompareOp
map_flags_t CompareOp
comparison operator specified on the depends line
Definition pkgcache.h:779
pkgCache::DependencyData::Version
map_stringitem_t Version
string of the version the dependency is applied against
Definition pkgcache.h:767
pkgCache::DependencyData::Package
map_pointer< pkgCache::Package > Package
index of the package this depends applies to
Definition pkgcache.h:772
pkgCache::DependencyData::Type
map_number_t Type
Dependency type - Depends, Recommends, Conflicts, etc.
Definition pkgcache.h:775
pkgCache::Dependency
Definition pkgcache.h:784
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:734
pkgCache::Description::NextDesc
map_pointer< Description > NextDesc
next translation for this description
Definition pkgcache.h:749
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:807
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