1 #ifndef APT_PRIVATE_CACHEFILE_H
2 #define APT_PRIVATE_CACHEFILE_H
4 #include <apt-pkg/cachefile.h>
5 #include <apt-pkg/progress.h>
6 #include <apt-pkg/configuration.h>
7 #include <apt-pkg/pkgcache.h>
8 #include <apt-pkg/macros.h>
9 #include <apt-pkg/sourcelist.h>
10 #include <apt-pkg/cacheset.h>
14 // FIXME: we need to find a way to export this
15 class APT_PUBLIC SourceList
: public pkgSourceList
18 // Add custom metaIndex (e.g. local files)
19 void AddMetaIndex(metaIndex
*mi
) {
20 SrcList
.push_back(mi
);
25 // class CacheFile - Cover class for some dependency cache functions /*{{{*/
26 class APT_PUBLIC CacheFile
: public pkgCacheFile
29 std::vector
<map_pointer_t
> UniverseList
;
31 bool CheckDeps(bool AllowBroken
= false);
32 bool BuildCaches(bool WithLock
= true)
34 OpTextProgress
Prog(*_config
);
35 if (pkgCacheFile::BuildCaches(&Prog
,WithLock
) == false)
39 // FIXME: this can go once the "libapt-pkg" pkgSourceList has a way
40 // to add custom metaIndexes (or custom local files or so)
41 bool BuildSourceList(OpProgress */
*Progress*/
= NULL
) {
44 SrcList
= new SourceList();
45 if (SrcList
->ReadMainList() == false)
46 return _error
->Error(_("The list of sources could not be read."));
49 bool Open(bool WithLock
= true)
51 OpTextProgress
Prog(*_config
);
52 return pkgCacheFile::Open(&Prog
,WithLock
);
56 if (_config
->FindB("APT::Get::Print-URIs") == true)
64 class APT_PUBLIC SortedPackageUniverse
: public APT::PackageUniverse
66 std::vector
<map_pointer_t
> &List
;
67 void LazyInit() const;
70 SortedPackageUniverse(CacheFile
&Cache
);
72 class const_iterator
: public APT::Container_iterator_base
<APT::PackageContainerInterface
, SortedPackageUniverse
, SortedPackageUniverse::const_iterator
, std::vector
<map_pointer_t
>::const_iterator
, pkgCache::PkgIterator
>
74 pkgCache
* const Cache
;
76 inline virtual pkgCache::PkgIterator
getType(void) const APT_OVERRIDE
78 if (*_iter
== 0) return pkgCache::PkgIterator(*Cache
);
79 return pkgCache::PkgIterator(*Cache
, Cache
->PkgP
+ *_iter
);
82 explicit const_iterator(pkgCache
* const Owner
, std::vector
<map_pointer_t
>::const_iterator i
):
83 Container_iterator_base
<APT::PackageContainerInterface
, SortedPackageUniverse
, SortedPackageUniverse::const_iterator
, std::vector
<map_pointer_t
>::const_iterator
, pkgCache::PkgIterator
>(i
), Cache(Owner
) {}
86 typedef const_iterator iterator
;
88 APT_PUBLIC const_iterator
begin() const { LazyInit(); return const_iterator(data(), List
.begin()); }
89 APT_PUBLIC const_iterator
end() const { LazyInit(); return const_iterator(data(), List
.end()); }
90 APT_PUBLIC const_iterator
cbegin() const { LazyInit(); return const_iterator(data(), List
.begin()); }
91 APT_PUBLIC const_iterator
cend() const { LazyInit(); return const_iterator(data(), List
.end()); }
92 APT_PUBLIC iterator
begin() { LazyInit(); return iterator(data(), List
.begin()); }
93 APT_PUBLIC iterator
end() { LazyInit(); return iterator(data(), List
.end()); }