X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b291aa59ee63983204d8aeb166c388b1f97edce7..bccb344412a0e97afdf0aaaf41a31124c84f6eaa:/apt-pkg/cacheiterators.h diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 4173326ca..62d0ab59c 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -35,6 +35,9 @@ #include #include #include +#ifdef APT_PKG_EXPOSE_STRING_VIEW +#include +#endif #include @@ -114,6 +117,10 @@ class pkgCache::GrpIterator: public Iterator { inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;} inline PkgIterator PackageList() const; PkgIterator FindPkg(std::string Arch = "any") const; +#ifdef APT_PKG_EXPOSE_STRING_VIEW + APT_HIDDEN PkgIterator FindPkg(APT::StringView Arch = APT::StringView("any", 3)) const; + APT_HIDDEN PkgIterator FindPkg(const char *Arch) const; +#endif /** \brief find the package with the "best" architecture The best architecture is either the "native" or the first @@ -157,11 +164,7 @@ class pkgCache::PkgIterator: public Iterator { inline const char *Name() const { return Group().Name(); } // Versions have sections - and packages can have different versions with different sections // so this interface is broken by design. Run as fast as you can to Version.Section(). - APT_DEPRECATED inline const char *Section() const { - APT_IGNORE_DEPRECATED_PUSH - return S->Section == 0?0:Owner->StrP + S->Section; - APT_IGNORE_DEPRECATED_POP - } + APT_DEPRECATED_MSG("Use the .Section method of VerIterator instead") inline const char *Section() const; inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge || (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);} inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;} @@ -172,11 +175,11 @@ class pkgCache::PkgIterator: public Iterator { inline DepIterator RevDependsList() const APT_PURE; inline PrvIterator ProvidesList() const APT_PURE; OkState State() const APT_PURE; - const char *CandVersion() const APT_PURE; + APT_DEPRECATED_MSG("This method does not respect apt_preferences! Use pkgDepCache::GetCandidateVersion(Pkg)") const char *CandVersion() const APT_PURE; const char *CurVersion() const APT_PURE; //Nice printable representation - friend std::ostream& operator <<(std::ostream& out, PkgIterator i); + APT_DEPRECATED_MSG("Use APT::PrettyPkg instead") friend std::ostream& operator <<(std::ostream& out, PkgIterator i); std::string FullName(bool const &Pretty = false) const; // Constructors @@ -211,14 +214,12 @@ class pkgCache::VerIterator : public Iterator { // 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;} -#if APT_PKG_ABI >= 413 /** \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;} /** \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;} -#endif inline const char *Arch() const { if ((S->MultiArch & pkgCache::Version::All) == pkgCache::Version::All) return "all"; @@ -297,7 +298,16 @@ class pkgCache::DepIterator : public Iterator { bool IsNegative() const APT_PURE; bool IsIgnorable(PrvIterator const &Prv) const APT_PURE; bool IsIgnorable(PkgIterator const &Pkg) const APT_PURE; - bool IsMultiArchImplicit() const APT_PURE; + /* MultiArch can be translated to SingleArch for an resolver and we did so, + by adding dependencies to help the resolver understand the problem, but + sometimes it is needed to identify these to ignore them… */ + inline bool IsMultiArchImplicit() const APT_PURE { + return (S2->CompareOp & pkgCache::Dep::MultiArchImplicit) == pkgCache::Dep::MultiArchImplicit; + } + /* This covers additionally negative dependencies, which aren't arch-specific, + but change architecture nonetheless as a Conflicts: foo does applies for all archs */ + bool IsImplicit() const APT_PURE; + bool IsSatisfied(VerIterator const &Ver) const APT_PURE; bool IsSatisfied(PrvIterator const &Prv) const APT_PURE; void GlobOr(DepIterator &Start,DepIterator &End); @@ -311,7 +321,7 @@ class pkgCache::DepIterator : public Iterator { { map_stringitem_t &Version; map_pointer_t &Package; - should_be_map_id_t &ID; + map_id_t &ID; unsigned char &Type; unsigned char &CompareOp; map_pointer_t &ParentVer; @@ -322,8 +332,8 @@ class pkgCache::DepIterator : public Iterator { DependencyProxy const * operator->() const { return this; } DependencyProxy * operator->() { return this; } }; - inline DependencyProxy operator->() const {return { S2->Version, S2->Package, S->ID, S2->Type, S2->CompareOp, S->ParentVer, S->DependencyData, S->NextRevDepends, S->NextDepends, S2->NextData };} - inline DependencyProxy operator->() {return { S2->Version, S2->Package, S->ID, S2->Type, S2->CompareOp, S->ParentVer, S->DependencyData, S->NextRevDepends, S->NextDepends, S2->NextData };} + 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 };} + 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 };} void ReMap(void const * const oldMap, void const * const newMap) { Iterator::ReMap(oldMap, newMap); @@ -333,7 +343,7 @@ class pkgCache::DepIterator : public Iterator { } //Nice printable representation - friend std::ostream& operator <<(std::ostream& out, DepIterator D); + APT_DEPRECATED_MSG("Use APT::PrettyDep instead") friend std::ostream& operator <<(std::ostream& out, DepIterator D); inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) : Iterator(Owner, Trg), Type(DepVer), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) { @@ -369,7 +379,12 @@ class pkgCache::PrvIterator : public Iterator { inline VerIterator OwnerVer() const {return VerIterator(*Owner,Owner->VerP + S->Version);} inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->Version].ParentPkg);} - bool IsMultiArchImplicit() const APT_PURE; + /* MultiArch can be translated to SingleArch for an resolver and we did so, + by adding provides to help the resolver understand the problem, but + sometimes it is needed to identify these to ignore them… */ + bool IsMultiArchImplicit() const APT_PURE + { return (S->Flags & pkgCache::Flag::MultiArchImplicit) == pkgCache::Flag::MultiArchImplicit; } + inline PrvIterator() : Iterator(), Type(PrvVer) {} inline PrvIterator(pkgCache &Owner, Provides *Trg, Version*) : @@ -506,5 +521,7 @@ inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);} inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);} +APT_DEPRECATED_MSG("Use the .Section method of VerIterator instead") inline const char * pkgCache::PkgIterator::Section() const + {return S->VersionList == 0 ? 0 : VersionList().Section();} /*}}}*/ #endif