]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheiterators.h
merged from mvo
[apt.git] / apt-pkg / cacheiterators.h
index d5a9c7b0db89712e79255783d808a92f9e00aade..af21681edf2f2dce79b455b3f0e09c8ce682dedb 100644 (file)
@@ -31,9 +31,6 @@
 #ifndef PKGLIB_CACHEITERATORS_H
 #define PKGLIB_CACHEITERATORS_H
 
-#ifdef __GNUG__
-#pragma interface "apt-pkg/cacheiterators.h"
-#endif 
 
 // Package Iterator
 class pkgCache::PkgIterator
@@ -83,7 +80,13 @@ class pkgCache::PkgIterator
    inline PrvIterator ProvidesList() const;
    inline unsigned long Index() const {return Pkg - Owner->PkgP;};
    OkState State() const;
-   
+
+   //Nice printable representation
+   friend std::ostream& operator<<(std::ostream& out, pkgCache::PkgIterator Pkg);
+
+   const char *CandVersion() const;
+   const char *CurVersion() const;
+
    // Constructors
    inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner),
           HashIndex(0) 
@@ -107,14 +110,17 @@ class pkgCache::VerIterator
    // Iteration
    void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver->NextVer;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Owner == NULL || (Ver == Owner->VerP?true:false);};
+   inline bool end() const {return Owner == 0 || (Ver == Owner->VerP?true:false);};
    inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Owner;};
    
    // Comparison
    inline bool operator ==(const VerIterator &B) const {return Ver == B.Ver;};
    inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver;};
    int CompareVer(const VerIterator &B) const;
-   
+
+   // Testing
+   inline bool IsGood() const { return Ver && Owner && ! end();};
+
    // Accessors
    inline Version *operator ->() {return Ver;};
    inline Version const *operator ->() const {return Ver;};
@@ -163,7 +169,7 @@ class pkgCache::DescIterator
    // Iteration
    void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + Desc->NextDesc;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Desc == Owner->DescP?true:false;};
+   inline bool end() const {return Owner == 0 || Desc == Owner->DescP?true:false;};
    inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B.Owner;};
    
    // Comparison
@@ -317,7 +323,7 @@ class pkgCache::PkgFileIterator
    // Iteration
    void operator ++(int) {if (File!= Owner->PkgFileP) File = Owner->PkgFileP + File->NextFile;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return File == Owner->PkgFileP?true:false;};
+   inline bool end() const {return Owner == 0 || File == Owner->PkgFileP?true:false;};
 
    // Comparison
    inline bool operator ==(const PkgFileIterator &B) const {return File == B.File;};
@@ -336,6 +342,7 @@ class pkgCache::PkgFileIterator
    inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
    inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
    inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
+   inline const char *Codename() const {return File->Codename ==0?0:Owner->StrP + File->Codename;};
    inline const char *Label() const {return File->Label == 0?0:Owner->StrP + File->Label;};
    inline const char *Site() const {return File->Site == 0?0:Owner->StrP + File->Site;};
    inline const char *Architecture() const {return File->Architecture == 0?0:Owner->StrP + File->Architecture;};
@@ -363,7 +370,7 @@ class pkgCache::VerFileIterator
    // Iteration
    void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerFileP + FileP->NextFile;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return FileP == Owner->VerFileP?true:false;};
+   inline bool end() const {return Owner == 0 || FileP == Owner->VerFileP?true:false;};
 
    // Comparison
    inline bool operator ==(const VerFileIterator &B) const {return FileP == B.FileP;};
@@ -395,7 +402,7 @@ class pkgCache::DescFileIterator
    // Iteration
    void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->DescFileP + FileP->NextFile;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return FileP == Owner->DescFileP?true:false;};
+   inline bool end() const {return Owner == 0 ||  FileP == Owner->DescFileP?true:false;};
 
    // Comparison
    inline bool operator ==(const DescFileIterator &B) const {return FileP == B.FileP;};