From a473295d01ed9c599926d9a8c212d4e1a404f78b Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 29 Nov 2016 22:40:20 -0800 Subject: Store tags in the cache (they are very useful :/). --- apt-pkg/cacheiterators.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'apt-pkg/cacheiterators.h') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 62d0ab59c..45d23151c 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -231,6 +231,7 @@ class pkgCache::VerIterator : public Iterator { DescIterator TranslatedDescription() const; inline DepIterator DependsList() const; inline PrvIterator ProvidesList() const; + inline TagIterator TagList() const; inline VerFileIterator FileList() const; bool Downloadable() const; inline const char *PriorityType() const {return Owner->Priority(S->Priority);} @@ -247,6 +248,48 @@ class pkgCache::VerIterator : public Iterator { inline VerIterator() : Iterator() {} }; /*}}}*/ +// Tag Iterator /*{{{*/ +class pkgCache::TagIterator +{ + Tag *Tg; + pkgCache *Owner; + + void _dummy(); + + public: + + // Iteration + void operator ++(int) {if (Tg != Owner->TagP) Tg = Owner->TagP + Tg->NextTag;}; + inline void operator ++() {operator ++(0);}; + inline bool end() const {return Tg == Owner->TagP?true:false;}; + inline void operator =(const TagIterator &B) {Tg = B.Tg; Owner = B.Owner;}; + + // Comparison + inline bool operator ==(const TagIterator &B) const {return Tg == B.Tg;}; + inline bool operator !=(const TagIterator &B) const {return Tg != B.Tg;}; + int CompareTag(const TagIterator &B) const; + + // Accessors + inline Tag *operator ->() {return Tg;}; + inline Tag const *operator ->() const {return Tg;}; + inline Tag &operator *() {return *Tg;}; + inline Tag const &operator *() const {return *Tg;}; + inline operator Tag *() {return Tg == Owner->TagP?0:Tg;}; + inline operator Tag const *() const {return Tg == Owner->TagP?0:Tg;}; + inline pkgCache *Cache() {return Owner;}; + + inline const char *Name() const {return Owner->StrP + Tg->Name;}; + inline unsigned long Index() const {return Tg - Owner->TagP;}; + + inline TagIterator() : Tg(0), Owner(0) {}; + inline TagIterator(pkgCache &Owner,Tag *Trg = 0) : Tg(Trg), + Owner(&Owner) + { + if (Tg == 0) + Tg = Owner.TagP; + }; +}; + /*}}}*/ // Description Iterator /*{{{*/ class pkgCache::DescIterator : public Iterator { public: @@ -515,6 +558,8 @@ inline pkgCache::DescIterator pkgCache::VerIterator::DescriptionList() const {return DescIterator(*Owner,Owner->DescP + S->DescriptionList);} inline pkgCache::PrvIterator pkgCache::VerIterator::ProvidesList() const {return PrvIterator(*Owner,Owner->ProvideP + S->ProvidesList,S);} +inline pkgCache::TagIterator pkgCache::VerIterator::TagList() const + {return TagIterator(*Owner,Owner->TagP + S->TagList);}; inline pkgCache::DepIterator pkgCache::VerIterator::DependsList() const {return DepIterator(*Owner,Owner->DepP + S->DependsList,S);} inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const -- cgit v1.2.3 From ef1e4dfd2853abb2e8900c26c1c17bf053863e85 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 29 Nov 2016 22:55:57 -0800 Subject: Most interfaces (Maemo) need a high-level name :/. --- apt-pkg/cacheiterators.h | 1 + 1 file changed, 1 insertion(+) (limited to 'apt-pkg/cacheiterators.h') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 45d23151c..3308f43dd 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -214,6 +214,7 @@ 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;} + inline const char *Display() const {return S->Display == 0?0:Owner->StrP + S->Display;} /** \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;} -- cgit v1.2.3 From c2fb49ca1783b9ea2dd8b7cb90a2284750076c65 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 31 Jan 2017 05:53:50 -0800 Subject: Port TagIterator to correctly support ReMap (doh). --- apt-pkg/cacheiterators.h | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'apt-pkg/cacheiterators.h') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 3308f43dd..5fb416d79 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -250,45 +250,30 @@ class pkgCache::VerIterator : public Iterator { }; /*}}}*/ // Tag Iterator /*{{{*/ -class pkgCache::TagIterator -{ - Tag *Tg; - pkgCache *Owner; - - void _dummy(); - - public: +class pkgCache::TagIterator : public Iterator { + public: + inline Tag* OwnerPointer() const { + return (Owner != 0) ? Owner->TagP : 0; + } // Iteration - void operator ++(int) {if (Tg != Owner->TagP) Tg = Owner->TagP + Tg->NextTag;}; + void operator ++(int) {if (S != Owner->TagP) S = Owner->TagP + S->NextTag;}; inline void operator ++() {operator ++(0);}; - inline bool end() const {return Tg == Owner->TagP?true:false;}; - inline void operator =(const TagIterator &B) {Tg = B.Tg; Owner = B.Owner;}; // Comparison - inline bool operator ==(const TagIterator &B) const {return Tg == B.Tg;}; - inline bool operator !=(const TagIterator &B) const {return Tg != B.Tg;}; + inline bool operator ==(const TagIterator &B) const {return S == B.S;}; + inline bool operator !=(const TagIterator &B) const {return S != B.S;}; int CompareTag(const TagIterator &B) const; // Accessors - inline Tag *operator ->() {return Tg;}; - inline Tag const *operator ->() const {return Tg;}; - inline Tag &operator *() {return *Tg;}; - inline Tag const &operator *() const {return *Tg;}; - inline operator Tag *() {return Tg == Owner->TagP?0:Tg;}; - inline operator Tag const *() const {return Tg == Owner->TagP?0:Tg;}; - inline pkgCache *Cache() {return Owner;}; - - inline const char *Name() const {return Owner->StrP + Tg->Name;}; - inline unsigned long Index() const {return Tg - Owner->TagP;}; - - inline TagIterator() : Tg(0), Owner(0) {}; - inline TagIterator(pkgCache &Owner,Tag *Trg = 0) : Tg(Trg), - Owner(&Owner) - { - if (Tg == 0) - Tg = Owner.TagP; - }; + inline const char *Name() const {return Owner->StrP + S->Name;}; + inline unsigned long Index() const {return S - Owner->TagP;}; + + inline TagIterator(pkgCache &Owner,Tag *Trg = 0) : Iterator(Owner, Trg) { + if (S == 0) + S = OwnerPointer(); + } + inline TagIterator() : Iterator() {} }; /*}}}*/ // Description Iterator /*{{{*/ -- cgit v1.2.3 From c7db7b2f8740c8c1ad859e9ad8f426fe601b5f04 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 1 Feb 2017 14:12:13 -0800 Subject: For ReMap to work, S has to be marked volatile :/. --- apt-pkg/cacheiterators.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/cacheiterators.h') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 5fb416d79..e594f3e7d 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -57,7 +57,7 @@ template class pkgCache::Iterator : Str* OwnerPointer() const { return static_cast(this)->OwnerPointer(); } protected: - Str *S; + Str *volatile S; pkgCache *Owner; public: -- cgit v1.2.3