]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheiterators.h
use the Valid-Until header from the Release file but if the user
[apt.git] / apt-pkg / cacheiterators.h
index 35d3aa22846ebc81fd0e975f497bd119da7be755..e2ca746838ce075977406c5d669607efc39504f7 100644 (file)
@@ -62,6 +62,7 @@ template<typename Str, typename Itr> class pkgCache::Iterator {
        inline Str const *operator ->() const {return S;};
        inline operator Str *() {return S == OwnerPointer() ? 0 : S;};
        inline operator Str const *() const {return S == OwnerPointer() ? 0 : S;};
+       inline Str &operator *() {return *S;};
        inline Str const &operator *() const {return *S;};
        inline pkgCache *Cache() {return Owner;};
 
@@ -81,13 +82,21 @@ template<typename Str, typename Itr> class pkgCache::Iterator {
    different architectures can be treated as of the "same" package
    (apt internally treat them as totally different packages) */
 class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
+       long HashIndex;
+
        protected:
        inline Group* OwnerPointer() const {
                return Owner->GrpP;
        };
 
        public:
-       void operator ++(int) {if (S != Owner->GrpP) S = Owner->GrpP + S->Next;};
+       // This constructor is the 'begin' constructor, never use it.
+       inline GrpIterator(pkgCache &Owner) : Iterator<Group, GrpIterator>(Owner), HashIndex(-1) {
+               S = OwnerPointer();
+               operator ++(0);
+       };
+
+       virtual void operator ++(int);
        virtual void operator ++() {operator ++(0);};
 
        inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;};
@@ -96,11 +105,11 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
        PkgIterator NextPkg(PkgIterator const &Pkg);
 
        // Constructors
-       inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg) {
+       inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg), HashIndex(0) {
                if (S == 0)
                        S = OwnerPointer();
        };
-       inline GrpIterator() : Iterator<Group, GrpIterator>() {};
+       inline GrpIterator() : Iterator<Group, GrpIterator>(), HashIndex(0) {};
 
 };
                                                                        /*}}}*/
@@ -143,6 +152,7 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> {
 
        //Nice printable representation
        friend std::ostream& operator <<(std::ostream& out, PkgIterator i);
+       std::string FullName(bool const &Pretty = false) const;
 
        // Constructors
        inline PkgIterator(pkgCache &Owner,Package *Trg) : Iterator<Package, PkgIterator>(Owner, Trg), HashIndex(0) {
@@ -170,7 +180,16 @@ class 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;};
-       inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;};
+       inline const char *Arch() const {
+               if(S->MultiArch == pkgCache::Version::All)
+                       return "all";
+               return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
+       };
+       inline const char *Arch(bool const pseudo) const {
+               if(pseudo == false)
+                       return Arch();
+               return S->ParentPkg == 0?0:Owner->StrP + ParentPkg()->Arch;
+       };
        inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + S->ParentPkg);};
 
        inline DescIterator DescriptionList() const;
@@ -183,6 +202,7 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
        string RelStr();
 
        bool Automatic() const;
+       bool Pseudo() const;
        VerFileIterator NewestFile() const;
 
        inline VerIterator(pkgCache &Owner,Version *Trg = 0) : Iterator<Version, VerIterator>(Owner, Trg) {
@@ -326,7 +346,8 @@ class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator>
 
        // Constructors
        inline PkgFileIterator() : Iterator<PackageFile, PkgFileIterator>() {};
-       inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg = 0) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {};
+       inline PkgFileIterator(pkgCache &Owner) : Iterator<PackageFile, PkgFileIterator>(Owner, Owner.PkgFileP) {};
+       inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Iterator<PackageFile, PkgFileIterator>(Owner, Trg) {};
 };
                                                                        /*}}}*/
 // Version File                                                                /*{{{*/