diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-15 16:37:19 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-15 16:37:19 +0100 |
| commit | 4bcb198a67156b2654f3b64173499ab78f0d4d9a (patch) | |
| tree | 769672dc89bc948e6018a82d50a6d990d6d73756 /apt-pkg/cacheiterators.h | |
| parent | f299c09e2eae51391a07ae8708ca789df721321a (diff) | |
cache: Introduce partial SourceVersion support
This is the first step that introduces a 1:1 mapping between version
and source version. In a future version this can use the fields
currently marked unavailable to deduplicate the SourceVersion
objects across the group.
The policy gains a member for storing pins for sourceversions.
Together, in the future we should be able to determine candidates
for source versions.
Diffstat (limited to 'apt-pkg/cacheiterators.h')
| -rw-r--r-- | apt-pkg/cacheiterators.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index ceeb4b3a7..443912253 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -188,6 +188,31 @@ class APT_PUBLIC pkgCache::PkgIterator: public Iterator<Package, PkgIterator> { inline PkgIterator() : Iterator<Package, PkgIterator>(), HashIndex(0) {} }; /*}}}*/ +// SourceVersion Iterator /*{{{*/ +class APT_PUBLIC pkgCache::SrcVerIterator : public Iterator<SourceVersion, SrcVerIterator> +{ + public: + inline SourceVersion *OwnerPointer() const + { + return (Owner != 0) ? Owner->SrcVerP : 0; + } +#if 0 + // Iteration + inline SrcVerIterator& operator++() {if (S != Owner->SrcVerP) S = Owner->SrcVerP + S->NextSourceVersion; return *this;} + inline SrcVerIterator operator++(int) { SrcVerIterator const tmp(*this); operator++(); return tmp; } +#endif + inline APT_PURE GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group); } + inline const char *VerStr() const { return S->VerStr == 0 ? 0 : Owner->StrP + S->VerStr; } + + inline SrcVerIterator(pkgCache &Owner, SourceVersion *Trg = 0) : Iterator<SourceVersion, SrcVerIterator>(Owner, Trg) + { + if (S == 0) + S = OwnerPointer(); + } + inline SrcVerIterator() : Iterator<SourceVersion, SrcVerIterator>() {} +}; + /*}}}*/ + // Version Iterator /*{{{*/ class APT_PUBLIC pkgCache::VerIterator : public Iterator<Version, VerIterator> { public: @@ -219,12 +244,15 @@ class APT_PUBLIC pkgCache::VerIterator : public Iterator<Version, VerIterator> { // Accessors inline const char *VerStr() const {return S->VerStr == 0?0:Owner->StrP + S->VerStr;} inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;} + /** \brief source version this version comes from + Always contains the version string, even if it is the same as the binary version */ + SrcVerIterator SourceVersion() const { return SrcVerIterator(*Owner, Owner->SrcVerP + S->SourceVersion); } /** \brief source package name this version comes from Always contains the name, even if it is the same as the binary name */ - inline const char *SourcePkgName() const {return Owner->StrP + S->SourcePkgName;} + inline const char *SourcePkgName() const { return SourceVersion().Group().Name(); } /** \brief source version this version comes from Always contains the version string, even if it is the same as the binary version */ - inline const char *SourceVerStr() const {return Owner->StrP + S->SourceVerStr;} + inline const char *SourceVerStr() const { return SourceVersion().VerStr(); } inline const char *Arch() const { if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All) return "all"; |
