private-cachefile.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef APT_PRIVATE_CACHEFILE_H
  2. #define APT_PRIVATE_CACHEFILE_H
  3. #include <apt-pkg/cachefile.h>
  4. #include <apt-pkg/progress.h>
  5. #include <apt-pkg/configuration.h>
  6. #include <apt-pkg/pkgcache.h>
  7. #include <apt-pkg/macros.h>
  8. #include <apt-pkg/sourcelist.h>
  9. #include <apt-pkg/cacheset.h>
  10. #include <apti18n.h>
  11. // class CacheFile - Cover class for some dependency cache functions /*{{{*/
  12. class APT_PUBLIC CacheFile : public pkgCacheFile
  13. {
  14. public:
  15. std::vector<map_pointer_t> UniverseList;
  16. bool CheckDeps(bool AllowBroken = false);
  17. bool BuildCaches(bool WithLock = true)
  18. {
  19. OpTextProgress Prog(*_config);
  20. if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false)
  21. return false;
  22. return true;
  23. }
  24. bool Open(bool WithLock = true)
  25. {
  26. OpTextProgress Prog(*_config);
  27. return pkgCacheFile::Open(&Prog,WithLock);
  28. };
  29. bool OpenForInstall()
  30. {
  31. if (_config->FindB("APT::Get::Print-URIs") == true)
  32. return Open(false);
  33. else
  34. return Open(true);
  35. }
  36. };
  37. /*}}}*/
  38. class SortedPackageUniverse : public APT::PackageUniverse
  39. {
  40. std::vector<map_pointer_t> &List;
  41. void LazyInit() const;
  42. public:
  43. explicit SortedPackageUniverse(CacheFile &Cache);
  44. class const_iterator : public APT::Container_iterator_base<APT::PackageContainerInterface, SortedPackageUniverse, SortedPackageUniverse::const_iterator, std::vector<map_pointer_t>::const_iterator, pkgCache::PkgIterator>
  45. {
  46. pkgCache * const Cache;
  47. public:
  48. inline pkgCache::PkgIterator getType(void) const
  49. {
  50. if (*_iter == 0) return pkgCache::PkgIterator(*Cache);
  51. return pkgCache::PkgIterator(*Cache, Cache->PkgP + *_iter);
  52. }
  53. explicit const_iterator(pkgCache * const Owner, std::vector<map_pointer_t>::const_iterator i):
  54. Container_iterator_base<APT::PackageContainerInterface, SortedPackageUniverse, SortedPackageUniverse::const_iterator, std::vector<map_pointer_t>::const_iterator, pkgCache::PkgIterator>(i), Cache(Owner) {}
  55. };
  56. typedef const_iterator iterator;
  57. const_iterator begin() const { LazyInit(); return const_iterator(data(), List.begin()); }
  58. const_iterator end() const { LazyInit(); return const_iterator(data(), List.end()); }
  59. const_iterator cbegin() const { LazyInit(); return const_iterator(data(), List.begin()); }
  60. const_iterator cend() const { LazyInit(); return const_iterator(data(), List.end()); }
  61. iterator begin() { LazyInit(); return iterator(data(), List.begin()); }
  62. iterator end() { LazyInit(); return iterator(data(), List.end()); }
  63. };
  64. #endif