summaryrefslogtreecommitdiff
path: root/apt-pkg/cacheiterators.h
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2017-01-31 05:53:50 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2017-01-31 05:53:50 -0800
commitc2fb49ca1783b9ea2dd8b7cb90a2284750076c65 (patch)
treedb40244c6491969ad652a4c257e36e6e44d20085 /apt-pkg/cacheiterators.h
parentf6877b4806585106a204cddcbc4640fc1d4a93ed (diff)
Port TagIterator to correctly support ReMap (doh).
Diffstat (limited to 'apt-pkg/cacheiterators.h')
-rw-r--r--apt-pkg/cacheiterators.h47
1 files changed, 16 insertions, 31 deletions
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<Version, VerIterator> {
};
/*}}}*/
// Tag Iterator /*{{{*/
-class pkgCache::TagIterator
-{
- Tag *Tg;
- pkgCache *Owner;
-
- void _dummy();
-
- public:
+class pkgCache::TagIterator : public Iterator<Tag, TagIterator> {
+ 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<Tag, TagIterator>(Owner, Trg) {
+ if (S == 0)
+ S = OwnerPointer();
+ }
+ inline TagIterator() : Iterator<Tag, TagIterator>() {}
};
/*}}}*/
// Description Iterator /*{{{*/