apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cacheiterators.h
Go to the documentation of this file.
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 :
48  public std::iterator<std::forward_iterator_tag, Str> {
49  /** \brief Returns the Pointer for this struct in the owner
50  * The implementation of this method should be pretty short
51  * as it will only return the Pointer into the mmap stored
52  * in the owner but the name of this pointer is different for
53  * each structure and we want to abstract here at least for the
54  * basic methods from the actual structure.
55  * \return Pointer to the first structure of this type
56  */
57  Str* OwnerPointer() const { return static_cast<Itr const*>(this)->OwnerPointer(); }
58 
59  protected:
60  Str *S;
62 
63  public:
64  // Iteration
65  inline bool end() const {return Owner == 0 || S == OwnerPointer();}
66 
67  // Comparison
68  inline bool operator ==(const Itr &B) const {return S == B.S;}
69  inline bool operator !=(const Itr &B) const {return S != B.S;}
70 
71  // Accessors
72  inline Str *operator ->() {return S;}
73  inline Str const *operator ->() const {return S;}
74  inline operator Str *() {return S == OwnerPointer() ? 0 : S;}
75  inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;}
76  inline Str &operator *() {return *S;}
77  inline Str const &operator *() const {return *S;}
78  inline pkgCache *Cache() const {return Owner;}
79 
80  // Mixed stuff
81  inline bool IsGood() const { return S && Owner && ! end();}
82  inline unsigned long Index() const {return S - OwnerPointer();}
83  inline map_pointer<Str> MapPointer() const {return map_pointer<Str>(Index()) ;}
84 
85  void ReMap(void const * const oldMap, void * const newMap) {
86  if (Owner == 0 || S == 0)
87  return;
88  S = static_cast<Str *>(newMap) + (S - static_cast<Str const *>(oldMap));
89  }
90 
91  // Constructors - look out for the variable assigning
92  inline Iterator() : S(0), Owner(0) {}
93  inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {}
94 };
95  /*}}}*/
96 // Group Iterator /*{{{*/
97 /* Packages with the same name are collected in a Group so someone only
98  interest in package names can iterate easily over the names, so the
99  different architectures can be treated as of the "same" package
100  (apt internally treat them as totally different packages) */
101 class APT_PUBLIC pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
102  long HashIndex;
103 
104  public:
105  inline Group* OwnerPointer() const {
106  return (Owner != 0) ? Owner->GrpP : 0;
107  }
108 
109  // This constructor is the 'begin' constructor, never use it.
110  explicit inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
111  S = OwnerPointer();
112  operator++();
113  }
114 
115  GrpIterator& operator++();
116  inline GrpIterator operator++(int) { GrpIterator const tmp(*this); operator++(); return tmp; }
117 
118  inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}
119  inline PkgIterator PackageList() const;
120  inline VerIterator VersionsInSource() const;
121  PkgIterator FindPkg(APT::StringView Arch = APT::StringView("any", 3)) const;
122  /** \brief find the package with the "best" architecture
123 
124  The best architecture is either the "native" or the first
125  in the list of Architectures which is not an end-Pointer
126 
127  \param PreferNonVirtual tries to respond with a non-virtual package
128  and only if this fails returns the best virtual package */
129  PkgIterator FindPreferredPkg(bool const &PreferNonVirtual = true) const;
130  PkgIterator NextPkg(PkgIterator const &Pkg) const;
131 
132  // Constructors
133  inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
134  if (S == 0)
135  S = OwnerPointer();
136  }
137  inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {}
138 
139 };
140  /*}}}*/
141 // Package Iterator /*{{{*/
142 class APT_PUBLIC pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
143  long HashIndex;
144 
145  public:
146  inline Package* OwnerPointer() const {
147  return (Owner != 0) ? Owner->PkgP : 0;
148  }
149 
150  // This constructor is the 'begin' constructor, never use it.
151  explicit inline PkgIterator(pkgCache &Owner) : Iterator<Package, PkgIterator>(Owner), HashIndex(-1) {
152  S = OwnerPointer();
153  operator++();
154  }
155 
156  PkgIterator& operator++();
157  inline PkgIterator operator++(int) { PkgIterator const tmp(*this); operator++(); return tmp; }
158 
159  enum OkState {NeedsNothing,NeedsUnpack,NeedsConfigure};
160 
161  // Accessors
162  inline const char *Name() const { return Group().Name(); }
163  inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
164  (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
165  inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}
166  inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}
167 
168  inline VerIterator VersionList() const APT_PURE;
169  inline VerIterator CurrentVer() const APT_PURE;
170  inline DepIterator RevDependsList() const APT_PURE;
171  inline PrvIterator ProvidesList() const APT_PURE;
173  const char *CurVersion() const APT_PURE;
174 
175  //Nice printable representation
176  APT_DEPRECATED_MSG("Use APT::PrettyPkg instead") friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
177  std::string FullName(bool const &Pretty = false) const;
178 
179  // Constructors
180  inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
181  if (S == 0)
182  S = OwnerPointer();
183  }
184  inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {}
185 };
186  /*}}}*/
187 // Version Iterator /*{{{*/
188 class APT_PUBLIC pkgCache::VerIterator : public Iterator<Version, VerIterator> {
189  public:
190  inline Version* OwnerPointer() const {
191  return (Owner != 0) ? Owner->VerP : 0;
192  }
193 
194  // Iteration
195  inline VerIterator& operator++() {if (S != Owner->VerP) S = Owner->VerP + S->NextVer; return *this;}
196  inline VerIterator operator++(int) { VerIterator const tmp(*this); operator++(); return tmp; }
197 
198  inline VerIterator NextInSource()
199  {
200  if (S != Owner->VerP)
201  S = Owner->VerP + S->NextInSource;
202  return *this;
203  }
204 
205  // Comparison
206  int CompareVer(const VerIterator &B) const;
207  /** \brief compares two version and returns if they are similar
208 
209  This method should be used to identify if two pseudo versions are
210  referring to the same "real" version */
211  inline bool SimilarVer(const VerIterator &B) const {
212  return (B.end() == false && S->Hash == B->Hash && strcmp(VerStr(), B.VerStr()) == 0);
213  }
214 
215  // Accessors
216  inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;}
217  inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}
218  /** \brief source package name this version comes from
219  Always contains the name, even if it is the same as the binary name */
220  inline const char *SourcePkgName() const {return Owner->StrP + S->SourcePkgName;}
221  /** \brief source version this version comes from
222  Always contains the version string, even if it is the same as the binary version */
223  inline const char *SourceVerStr() const {return Owner->StrP + S->SourceVerStr;}
224  inline const char *Arch() const {
225  if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All)
226  return "all";
227  return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
228  }
229  inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
230 
231  inline DescIterator DescriptionList() const;
233  DescIterator TranslatedDescription() const;
234  inline DepIterator DependsList() const;
235  inline PrvIterator ProvidesList() const;
236  inline VerFileIterator FileList() const;
237  bool Downloadable() const;
238  inline const char *PriorityType() const {return Owner->Priority(S->Priority);}
239  const char *MultiArchType() const APT_PURE;
240  std::string RelStr() const;
241 
242  bool Automatic() const;
243  VerFileIterator NewestFile() const;
244 
245 #ifdef APT_COMPILING_APT
246  inline unsigned int PhasedUpdatePercentage() const
247  {
248  return (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage;
249  }
250  inline bool PhasedUpdatePercentage(unsigned int percentage)
251  {
252  if (percentage > 100)
253  return false;
254  (static_cast<Version::Extra *>(Owner->Map.Data()) + S->d)->PhasedUpdatePercentage = static_cast<uint8_t>(percentage);
255  return true;
256  }
257 #endif
258 
259  inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
260  if (S == 0)
261  S = OwnerPointer();
262  }
263  inline VerIterator() : Iterator<Version, VerIterator>() {}
264 };
265  /*}}}*/
266 // Description Iterator /*{{{*/
267 class APT_PUBLIC pkgCache::DescIterator : public Iterator<Description, DescIterator> {
268  public:
269  inline Description* OwnerPointer() const {
270  return (Owner != 0) ? Owner->DescP : 0;
271  }
272 
273  // Iteration
274  inline DescIterator& operator++() {if (S != Owner->DescP) S = Owner->DescP + S->NextDesc; return *this;}
275  inline DescIterator operator++(int) { DescIterator const tmp(*this); operator++(); return tmp; }
276 
277  // Comparison
278  int CompareDesc(const DescIterator &B) const;
279 
280  // Accessors
281  inline const char *LanguageCode() const {return Owner->StrP + S->language_code;}
282  inline const char *md5() const {return Owner->StrP + S->md5sum;}
283  inline DescFileIterator FileList() const;
284 
285  inline DescIterator() : Iterator<Description, DescIterator>() {}
286  inline DescIterator(pkgCache &Owner,Description *Trg = 0) : Iterator<Description, DescIterator>(Owner, Trg) {
287  if (S == 0)
288  S = Owner.DescP;
289  }
290 };
291  /*}}}*/
292 // Dependency iterator /*{{{*/
293 class APT_PUBLIC pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
294  enum {DepVer, DepRev} Type;
296 
297  public:
298  inline Dependency* OwnerPointer() const {
299  return (Owner != 0) ? Owner->DepP : 0;
300  }
301 
302  // Iteration
303  DepIterator& operator++();
304  inline DepIterator operator++(int) { DepIterator const tmp(*this); operator++(); return tmp; }
305 
306  // Accessors
307  inline const char *TargetVer() const {return S2->Version == 0?0:Owner->StrP + S2->Version;}
308  inline PkgIterator TargetPkg() const {return PkgIterator(*Owner,Owner->PkgP + S2->Package);}
309  inline PkgIterator SmartTargetPkg() const {PkgIterator R(*Owner,0);SmartTargetPkg(R);return R;}
310  inline VerIterator ParentVer() const {return VerIterator(*Owner,Owner->VerP + S->ParentVer);}
311  inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->ParentVer)].ParentPkg);}
312  inline bool Reverse() const {return Type == DepRev;}
313  bool IsCritical() const APT_PURE;
314  bool IsNegative() const APT_PURE;
315  bool IsIgnorable(PrvIterator const &Prv) const APT_PURE;
316  bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE;
317  /* MultiArch can be translated to SingleArch for an resolver and we did so,
318  by adding dependencies to help the resolver understand the problem, but
319  sometimes it is needed to identify these to ignore them… */
320  inline bool IsMultiArchImplicit() const APT_PURE {
322  }
323  /* This covers additionally negative dependencies, which aren't arch-specific,
324  but change architecture nonetheless as a Conflicts: foo does applies for all archs */
325  bool IsImplicit() const APT_PURE;
326 
327  bool IsSatisfied(VerIterator const &Ver) const APT_PURE;
328  bool IsSatisfied(PrvIterator const &Prv) const APT_PURE;
329  void GlobOr(DepIterator &Start,DepIterator &End);
330  Version **AllTargets() const;
331  bool SmartTargetPkg(PkgIterator &Result) const;
332  inline const char *CompType() const {return Owner->CompType(S2->CompareOp);}
333  inline const char *DepType() const {return Owner->DepType(S2->Type);}
334 
335  // overrides because we are special
337  {
341  unsigned char &Type;
342  unsigned char &CompareOp;
348  DependencyProxy const * operator->() const { return this; }
349  DependencyProxy * operator->() { return this; }
350  };
351  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 };}
352  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 };}
353  void ReMap(void const * const oldMap, void * const newMap)
354  {
356  if (Owner == 0 || S == 0 || S2 == 0)
357  return;
358  S2 = static_cast<DependencyData *>(newMap) + (S2 - static_cast<DependencyData const *>(oldMap));
359  }
360 
361  //Nice printable representation
362  APT_DEPRECATED_MSG("Use APT::PrettyDep instead") friend std::ostream& operator <<(std::ostream& out, DepIterator D);
363 
364  inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) :
365  Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepVer), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
366  if (S == 0)
367  S = Owner.DepP;
368  }
369  inline DepIterator(pkgCache &Owner, Dependency *Trg, Package*) :
370  Iterator<Dependency, DepIterator>(Owner, Trg), Type(DepRev), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) {
371  if (S == 0)
372  S = Owner.DepP;
373  }
374  inline DepIterator() : Iterator<Dependency, DepIterator>(), Type(DepVer), S2(0) {}
375 };
376  /*}}}*/
377 // Provides iterator /*{{{*/
378 class APT_PUBLIC pkgCache::PrvIterator : public Iterator<Provides, PrvIterator> {
379  enum {PrvVer, PrvPkg} Type;
380 
381  public:
382  inline Provides* OwnerPointer() const {
383  return (Owner != 0) ? Owner->ProvideP : 0;
384  }
385 
386  // Iteration
387  inline PrvIterator& operator ++() {if (S != Owner->ProvideP) S = Owner->ProvideP +
388  (Type == PrvVer?S->NextPkgProv:S->NextProvides); return *this;}
389  inline PrvIterator operator++(int) { PrvIterator const tmp(*this); operator++(); return tmp; }
390 
391  // Accessors
392  inline const char *Name() const {return ParentPkg().Name();}
393  inline const char *ProvideVersion() const {return S->ProvideVersion == 0?0:Owner->StrP + S->ProvideVersion;}
394  inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);}
395  inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);}
396  inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[uint32_t(S->Version)].ParentPkg);}
397 
398  /* MultiArch can be translated to SingleArch for an resolver and we did so,
399  by adding provides to help the resolver understand the problem, but
400  sometimes it is needed to identify these to ignore them… */
403 
404 
405  inline PrvIterator() : Iterator<Provides, PrvIterator>(), Type(PrvVer) {}
406  inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) :
407  Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvVer) {
408  if (S == 0)
409  S = Owner.ProvideP;
410  }
411  inline PrvIterator(pkgCache &Owner, Provides *Trg, Package*) :
412  Iterator<Provides, PrvIterator>(Owner, Trg), Type(PrvPkg) {
413  if (S == 0)
414  S = Owner.ProvideP;
415  }
416 };
417  /*}}}*/
418 // Release file /*{{{*/
419 class APT_PUBLIC pkgCache::RlsFileIterator : public Iterator<ReleaseFile, RlsFileIterator> {
420  public:
421  inline ReleaseFile* OwnerPointer() const {
422  return (Owner != 0) ? Owner->RlsFileP : 0;
423  }
424 
425  // Iteration
426  inline RlsFileIterator& operator++() {if (S != Owner->RlsFileP) S = Owner->RlsFileP + S->NextFile;return *this;}
427  inline RlsFileIterator operator++(int) { RlsFileIterator const tmp(*this); operator++(); return tmp; }
428 
429  // Accessors
430  inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
431  inline const char *Archive() const {return S->Archive == 0?0:Owner->StrP + S->Archive;}
432  inline const char *Version() const {return S->Version == 0?0:Owner->StrP + S->Version;}
433  inline const char *Origin() const {return S->Origin == 0?0:Owner->StrP + S->Origin;}
434  inline const char *Codename() const {return S->Codename ==0?0:Owner->StrP + S->Codename;}
435  inline const char *Label() const {return S->Label == 0?0:Owner->StrP + S->Label;}
436  inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;}
437  inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return (S->Flags & flag) == flag; }
438 
439  std::string RelStr();
440 
441  // Constructors
442  inline RlsFileIterator() : Iterator<ReleaseFile, RlsFileIterator>() {}
443  explicit inline RlsFileIterator(pkgCache &Owner) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Owner.RlsFileP) {}
444  inline RlsFileIterator(pkgCache &Owner,ReleaseFile *Trg) : Iterator<ReleaseFile, RlsFileIterator>(Owner, Trg) {}
445 };
446  /*}}}*/
447 // Package file /*{{{*/
448 class APT_PUBLIC pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> {
449  public:
450  inline PackageFile* OwnerPointer() const {
451  return (Owner != 0) ? Owner->PkgFileP : 0;
452  }
453 
454  // Iteration
455  inline PkgFileIterator& operator++() {if (S != Owner->PkgFileP) S = Owner->PkgFileP + S->NextFile; return *this;}
456  inline PkgFileIterator operator++(int) { PkgFileIterator const tmp(*this); operator++(); return tmp; }
457 
458  // Accessors
459  inline const char *FileName() const {return S->FileName == 0?0:Owner->StrP + S->FileName;}
460  inline pkgCache::RlsFileIterator ReleaseFile() const {return RlsFileIterator(*Owner, Owner->RlsFileP + S->Release);}
461  inline const char *Archive() const {return S->Release == 0 ? Component() : ReleaseFile().Archive();}
462  inline const char *Version() const {return S->Release == 0 ? NULL : ReleaseFile().Version();}
463  inline const char *Origin() const {return S->Release == 0 ? NULL : ReleaseFile().Origin();}
464  inline const char *Codename() const {return S->Release == 0 ? NULL : ReleaseFile().Codename();}
465  inline const char *Label() const {return S->Release == 0 ? NULL : ReleaseFile().Label();}
466  inline const char *Site() const {return S->Release == 0 ? NULL : ReleaseFile().Site();}
467  inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return S->Release== 0 ? false : ReleaseFile().Flagged(flag);}
468  inline bool Flagged(pkgCache::Flag::PkgFFlags const flag) const {return (S->Flags & flag) == flag;}
469  inline const char *Component() const {return S->Component == 0?0:Owner->StrP + S->Component;}
470  inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;}
471  inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}
472 
473  std::string RelStr();
474 
475  // Constructors
476  inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {}
477  explicit inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {}
478  inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {}
479 };
480  /*}}}*/
481 // Version File /*{{{*/
482 class APT_PUBLIC pkgCache::VerFileIterator : public pkgCache::Iterator<VerFile, VerFileIterator> {
483  public:
484  inline VerFile* OwnerPointer() const {
485  return (Owner != 0) ? Owner->VerFileP : 0;
486  }
487 
488  // Iteration
489  inline VerFileIterator& operator++() {if (S != Owner->VerFileP) S = Owner->VerFileP + S->NextFile; return *this;}
490  inline VerFileIterator operator++(int) { VerFileIterator const tmp(*this); operator++(); return tmp; }
491 
492  // Accessors
493  inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
494 
495  inline VerFileIterator() : Iterator<VerFile, VerFileIterator>() {}
496  inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Iterator<VerFile, VerFileIterator>(Owner, Trg) {}
497 };
498  /*}}}*/
499 // Description File /*{{{*/
500 class APT_PUBLIC pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> {
501  public:
502  inline DescFile* OwnerPointer() const {
503  return (Owner != 0) ? Owner->DescFileP : 0;
504  }
505 
506  // Iteration
507  inline DescFileIterator& operator++() {if (S != Owner->DescFileP) S = Owner->DescFileP + S->NextFile; return *this;}
508  inline DescFileIterator operator++(int) { DescFileIterator const tmp(*this); operator++(); return tmp; }
509 
510  // Accessors
511  inline PkgFileIterator File() const {return PkgFileIterator(*Owner, Owner->PkgFileP + S->File);}
512 
513  inline DescFileIterator() : Iterator<DescFile, DescFileIterator>() {}
514  inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Iterator<DescFile, DescFileIterator>(Owner, Trg) {}
515 };
516  /*}}}*/
517 // Inlined Begin functions can't be in the class because of order problems /*{{{*/
519  {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}
520  inline pkgCache::VerIterator pkgCache::GrpIterator::VersionsInSource() const
521  {
522  return VerIterator(*Owner, Owner->VerP + S->VersionsInSource);
523  }
525  {return VerIterator(*Owner,Owner->VerP + S->VersionList);}
526 inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
527  {return VerIterator(*Owner,Owner->VerP + S->CurrentVer);}
528 inline pkgCache::DepIterator pkgCache::PkgIterator::RevDependsList() const
529  {return DepIterator(*Owner,Owner->DepP + S->RevDepends,S);}
530 inline pkgCache::PrvIterator pkgCache::PkgIterator::ProvidesList() const
531  {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
532 inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const
533  {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);}
534 inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const
535  {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);}
536 inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const
537  {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);}
538 inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
539  {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
540 inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
541  {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
542  /*}}}*/
543 #endif
return false
Simple subset of std::string_view from C++17.
Definition: string_view.h:27
RlsFileIterator & operator++()
VerIterator NextInSource()
PkgIterator(pkgCache &Owner)
Provides * ProvideP
Definition: pkgcache.h:230
int CompareDesc(const DescIterator &B) const
const char * Codename() const
int CompareVer(const VerIterator &B) const
const char * Archive() const
bool IsGood() const
std::string RelStr()
DescIterator(pkgCache &Owner, Description *Trg=0)
PkgFileIterator operator++(int)
PkgIterator & operator++()
Provides * OwnerPointer() const
bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const
bool operator!=(const Itr &B) const
void ReMap(void const *const oldMap, void *const newMap)
PkgIterator SmartTargetPkg() const
Dependency * DepP
Definition: pkgcache.h:231
PkgFileIterator File() const
map_pointer< Str > MapPointer() const
const char * Site() const
DepIterator & operator++()
const char * ProvideVersion() const
PkgIterator FindPkg(APT::StringView Arch=APT::StringView("any", 3)) const
VerIterator VersionsInSource() const
const char * Version() const
bool Reverse() const
VerFileIterator & operator++()
const char * md5() const
Version * OwnerPointer() const
PrvIterator operator++(int)
DescFile * OwnerPointer() const
Iterator(pkgCache &Owner, Str *T=0)
PackageFile * OwnerPointer() const
bool SimilarVer(const VerIterator &B) const
compares two version and returns if they are similar
Description * DescP
Definition: pkgcache.h:229
pkgCache::RlsFileIterator ReleaseFile() const
const char * Architecture() const
VerIterator operator++(int)
DependencyData * S2
PrvIterator(pkgCache &Owner, Provides *Trg, Version *)
bool IsMultiArchImplicit() const APT_PURE
PkgFileIterator(pkgCache &Owner)
DepIterator operator++(int)
unsigned long Index() const
RlsFileIterator(pkgCache &Owner)
PkgFileIterator & operator++()
DescIterator TranslatedDescription() const
DependencyProxy operator->()
const char * Component() const
VerFileIterator(pkgCache &Owner, VerFile *Trg)
DescIterator DescriptionList() const
bool IsCritical() const APT_PURE
const char * Section() const
VerIterator(pkgCache &Owner, Version *Trg=0)
PkgIterator TargetPkg() const
PkgFileIterator(pkgCache &Owner, PackageFile *Trg)
PkgIterator OwnerPkg() const
PkgIterator FindPreferredPkg(bool const &PreferNonVirtual=true) const
find the package with the "best" architecture
ReleaseFile * OwnerPointer() const
Package * OwnerPointer() const
const char * VerStr() const
PrvIterator(pkgCache &Owner, Provides *Trg, Package *)
const char * IndexType() const
pkgCache * Owner
VerIterator VersionList() const APT_PURE
const char * Origin() const
DependencyProxy operator->() const
long HashIndex
PkgIterator operator++(int)
bool operator==(const Itr &B) const
enum pkgCache::@1 Type
const char * LanguageCode() const
Str * operator->()
DescIterator operator++(int)
const char * SourceVerStr() const
source version this version comes from Always contains the version string, even if it is the same as ...
DescIterator TranslatedDescriptionForLanguage(APT::StringView lang) const
const char * SourcePkgName() const
source package name this version comes from Always contains the name, even if it is the same as the b...
RlsFileIterator(pkgCache &Owner, ReleaseFile *Trg)
PrvIterator ProvidesList() const
const char * PriorityType() const
GrpIterator(pkgCache &Owner, Group *Trg)
const char * Label() const
bool Downloadable() const
GrpIterator(pkgCache &Owner)
const char * MultiArchType() const APT_PURE
VerFileIterator operator++(int)
DescFileIterator FileList() const
const char * Name() const
PkgIterator ParentPkg() const
bool Flagged(pkgCache::Flag::PkgFFlags const flag) const
Str & operator*()
DescFileIterator operator++(int)
const char * DepType() const
VerIterator OwnerVer() const
Description * OwnerPointer() const
PkgIterator NextPkg(PkgIterator const &Pkg) const
PkgIterator PackageList() const
DepIterator(pkgCache &Owner, Dependency *Trg, Package *)
VerIterator & operator++()
APT_PURE GrpIterator Group() const
const char * TargetVer() const
DescFileIterator & operator++()
GrpIterator operator++(int)
Str * OwnerPointer() const
Returns the Pointer for this struct in the owner The implementation of this method should be pretty s...
const char * FileName() const
GrpIterator & operator++()
Dependency * OwnerPointer() const
VerFileIterator FileList() const
RlsFileIterator operator++(int)
bool Purge() const
bool IsImplicit() const APT_PURE
Group * OwnerPointer() const
DepIterator DependsList() const
DescFileIterator(pkgCache &Owner, DescFile *Trg)
DescIterator & operator++()
const char * Arch() const
bool end() const
VerIterator ParentVer() const
VerFile * OwnerPointer() const
pkgCache * Cache() const
#define APT_PURE
Definition: macros.h:56
#define APT_PUBLIC
Definition: macros.h:77
#define APT_DEPRECATED_MSG
Definition: macros.h:55
VersionContainer< std::list< pkgCache::VerIterator > > VersionList
Definition: cacheset.h:1063
PackageContainer< std::list< pkgCache::PkgIterator > > PackageList
Definition: cacheset.h:681
uint32_t map_id_t
Definition: pkgcache.h:93
@ MultiArchImplicit
Definition: pkgcache.h:175
information for a single dependency record
Definition: pkgcache.h:738
map_flags_t CompareOp
comparison operator specified on the depends line
Definition: pkgcache.h:752
map_stringitem_t Version
string of the version the dependency is applied against
Definition: pkgcache.h:740
map_pointer< pkgCache::Package > Package
index of the package this depends applies to
Definition: pkgcache.h:745
map_pointer< DependencyData > NextData
Definition: pkgcache.h:754
map_number_t Type
Dependency type - Depends, Recommends, Conflicts, etc.
Definition: pkgcache.h:748
map_pointer< Dependency > & NextRevDepends
map_pointer< pkgCache::Package > & Package
map_pointer< Dependency > & NextDepends
map_pointer< pkgCache::DependencyData > & NextData
DependencyProxy const * operator->() const
DependencyProxy * operator->()
map_stringitem_t & Version
map_pointer< pkgCache::DependencyData > & DependencyData
map_pointer< pkgCache::Version > & ParentVer
associates a description with a Translation file
Definition: pkgcache.h:607
datamember of a linked list of available description for a version
Definition: pkgcache.h:707
groups architecture depending packages together
Definition: pkgcache.h:415
stores information about the files used to generate the cache
Definition: pkgcache.h:552
contains information for a single unique package
Definition: pkgcache.h:450
handles virtual packages
Definition: pkgcache.h:780
stores information about the release files used to generate the cache
Definition: pkgcache.h:508
associates a version with a PackageFile
Definition: pkgcache.h:593
information for a single version of a package
Definition: pkgcache.h:625