]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheset.h
add basic "edit-sources" command
[apt.git] / apt-pkg / cacheset.h
index a23659efbb5c6beed35a05b55fec8c850afe3175..29103aad9c3f4cffb5dd66c498cb20a5bb02dc57 100644 (file)
@@ -11,7 +11,6 @@
 // Include Files                                                       /*{{{*/
 #include <iostream>
 #include <fstream>
-#include <list>
 #include <map>
 #include <set>
 #include <list>
 
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgcache.h>
+
+#ifndef APT_8_CLEANER_HEADERS
+#include <apt-pkg/cachefile.h>
+#endif
                                                                        /*}}}*/
 
 class pkgCacheFile;
@@ -128,13 +131,15 @@ public:
        virtual bool empty() const = 0;
        virtual void clear() = 0;
 
-       enum Constructor { UNKNOWN, REGEX, TASK };
+       enum Constructor { UNKNOWN, REGEX, TASK, FNMATCH };
        virtual void setConstructor(Constructor const &con) = 0;
        virtual Constructor getConstructor() const = 0;
 
        static bool FromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
        static bool FromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
        static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper);
+       static bool FromFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
+       static bool FromGroup(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
        static bool FromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper);
        static bool FromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper);
 
@@ -168,7 +173,8 @@ public:                                                                     /*{{{*/
                pkgCache::PkgIterator getPkg(void) const { return *_iter; }
                inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
                operator typename Container::const_iterator(void) const { return _iter; }
-               inline void operator++(void) { ++_iter; };
+               inline const_iterator& operator++() { ++_iter; return *this; }
+               inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
                inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; };
                inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
                friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
@@ -181,10 +187,13 @@ public:                                                                   /*{{{*/
                pkgCache::PkgIterator getPkg(void) const { return *_iter; }
                inline pkgCache::PkgIterator operator*(void) const { return *_iter; };
                operator typename Container::iterator(void) const { return _iter; }
-               operator typename PackageContainer<Container>::const_iterator() { return PackageContainer<Container>::const_iterator(_iter); }
-               inline void operator++(void) { ++_iter; };
+               operator typename PackageContainer<Container>::const_iterator() { return typename PackageContainer<Container>::const_iterator(_iter); }
+               inline iterator& operator++() { ++_iter; return *this; }
+               inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
                inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
                inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+               inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
+               inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
                friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
        };
                                                                        /*}}}*/
@@ -195,7 +204,9 @@ public:                                                                     /*{{{*/
 
        bool empty() const { return _cont.empty(); };
        void clear() { return _cont.clear(); };
+       //FIXME: on ABI break, replace the first with the second without bool
        void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+       iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
        size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); };
        void erase(iterator first, iterator last) { _cont.erase(first, last); };
        size_t size() const { return _cont.size(); };
@@ -249,6 +260,16 @@ public:                                                                    /*{{{*/
                return FromRegEx(Cache, pattern, helper);
        }
 
+       static PackageContainer FromFnmatch(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
+               PackageContainer cont(FNMATCH);
+               PackageContainerInterface::FromFnmatch(&cont, Cache, pattern, helper);
+               return cont;
+       }
+       static PackageContainer FromFnMatch(pkgCacheFile &Cache, std::string const &pattern) {
+               CacheSetHelper helper;
+               return FromFnmatch(Cache, pattern, helper);
+       }
+
        /** \brief returns a package specified by a string
 
            \param Cache the package is in
@@ -482,7 +503,8 @@ public:                                                                     /*{{{*/
                pkgCache::VerIterator getVer(void) const { return *_iter; }
                inline pkgCache::VerIterator operator*(void) const { return *_iter; };
                operator typename Container::const_iterator(void) const { return _iter; }
-               inline void operator++(void) { ++_iter; };
+               inline const_iterator& operator++() { ++_iter; return *this; }
+               inline const_iterator operator++(int) { const_iterator tmp(*this); operator++(); return tmp; }
                inline bool operator!=(const_iterator const &i) const { return _iter != i._iter; };
                inline bool operator==(const_iterator const &i) const { return _iter == i._iter; };
                friend std::ostream& operator<<(std::ostream& out, const_iterator i) { return operator<<(out, *i); }
@@ -495,10 +517,13 @@ public:                                                                   /*{{{*/
                pkgCache::VerIterator getVer(void) const { return *_iter; }
                inline pkgCache::VerIterator operator*(void) const { return *_iter; };
                operator typename Container::iterator(void) const { return _iter; }
-               operator typename VersionContainer<Container>::const_iterator() { return VersionContainer<Container>::const_iterator(_iter); }
-               inline void operator++(void) { ++_iter; };
+               operator typename VersionContainer<Container>::const_iterator() { return typename VersionContainer<Container>::const_iterator(_iter); }
+               inline iterator& operator++() { ++_iter; return *this; }
+               inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
                inline bool operator!=(iterator const &i) const { return _iter != i._iter; };
                inline bool operator==(iterator const &i) const { return _iter == i._iter; };
+               inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; };
+               inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; };
                friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); }
        };
                                                                        /*}}}*/
@@ -508,7 +533,9 @@ public:                                                                     /*{{{*/
        void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); };
        bool empty() const { return _cont.empty(); };
        void clear() { return _cont.clear(); };
+       //FIXME: on ABI break, replace the first with the second without bool
        void erase(iterator position) { _cont.erase((typename Container::iterator)position); };
+       iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); };
        size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); };
        void erase(iterator first, iterator last) { _cont.erase(first, last); };
        size_t size() const { return _cont.size(); };