debindexfile.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Debian Index Files
  5. There are three sorts currently
  6. Package files that have File: tags
  7. Package files that don't (/var/lib/dpkg/status)
  8. Source files
  9. ##################################################################### */
  10. /*}}}*/
  11. #ifndef PKGLIB_DEBINDEXFILE_H
  12. #define PKGLIB_DEBINDEXFILE_H
  13. #include <apt-pkg/indexfile.h>
  14. #include <apt-pkg/cacheiterators.h>
  15. #include <apt-pkg/pkgcache.h>
  16. #include <apt-pkg/srcrecords.h>
  17. #include <string>
  18. class OpProgress;
  19. class pkgAcquire;
  20. class pkgCacheGenerator;
  21. class APT_HIDDEN debStatusIndex : public pkgIndexFile
  22. {
  23. void * const d;
  24. protected:
  25. std::string File;
  26. public:
  27. virtual const Type *GetType() const APT_CONST;
  28. // Interface for acquire
  29. virtual std::string Describe(bool /*Short*/) const APT_OVERRIDE {return File;};
  30. // Interface for the Cache Generator
  31. virtual bool Exists() const APT_OVERRIDE;
  32. virtual bool HasPackages() const APT_OVERRIDE {return true;};
  33. virtual unsigned long Size() const APT_OVERRIDE;
  34. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE;
  35. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
  36. debStatusIndex(std::string File);
  37. virtual ~debStatusIndex();
  38. };
  39. class APT_HIDDEN debPackagesIndex : public pkgIndexTargetFile
  40. {
  41. void * const d;
  42. public:
  43. virtual const Type *GetType() const APT_CONST;
  44. // Stuff for accessing files on remote items
  45. virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const APT_OVERRIDE;
  46. // Interface for the Cache Generator
  47. virtual bool HasPackages() const APT_OVERRIDE {return true;};
  48. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE;
  49. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
  50. debPackagesIndex(IndexTarget const &Target, bool const Trusted);
  51. virtual ~debPackagesIndex();
  52. };
  53. class APT_HIDDEN debTranslationsIndex : public pkgIndexTargetFile
  54. {
  55. void * const d;
  56. public:
  57. virtual const Type *GetType() const APT_CONST;
  58. // Interface for the Cache Generator
  59. virtual bool HasPackages() const APT_OVERRIDE;
  60. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE;
  61. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
  62. debTranslationsIndex(IndexTarget const &Target);
  63. virtual ~debTranslationsIndex();
  64. };
  65. class APT_HIDDEN debSourcesIndex : public pkgIndexTargetFile
  66. {
  67. void * const d;
  68. public:
  69. virtual const Type *GetType() const APT_CONST;
  70. // Stuff for accessing files on remote items
  71. virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
  72. pkgSrcRecords::File const &File) const APT_OVERRIDE;
  73. // Interface for the record parsers
  74. virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
  75. // Interface for the Cache Generator
  76. virtual bool HasPackages() const APT_OVERRIDE {return false;};
  77. debSourcesIndex(IndexTarget const &Target, bool const Trusted);
  78. virtual ~debSourcesIndex();
  79. };
  80. class APT_HIDDEN debDebPkgFileIndex : public pkgIndexFile
  81. {
  82. private:
  83. void * const d;
  84. std::string DebFile;
  85. std::string DebFileFullPath;
  86. public:
  87. virtual const Type *GetType() const APT_CONST;
  88. virtual std::string Describe(bool /*Short*/) const APT_OVERRIDE {
  89. return DebFile;
  90. }
  91. /** get the control (file) content of the deb file
  92. *
  93. * @param[out] content of the control file
  94. * @param debfile is the filename of the .deb-file
  95. * @return \b true if successful, otherwise \b false.
  96. */
  97. static bool GetContent(std::ostream &content, std::string const &debfile);
  98. // Interface for the Cache Generator
  99. virtual bool Exists() const APT_OVERRIDE;
  100. virtual bool HasPackages() const APT_OVERRIDE {
  101. return true;
  102. };
  103. virtual unsigned long Size() const APT_OVERRIDE;
  104. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const APT_OVERRIDE;
  105. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
  106. // Interface for acquire
  107. virtual std::string ArchiveURI(std::string /*File*/) const APT_OVERRIDE;
  108. debDebPkgFileIndex(std::string DebFile);
  109. virtual ~debDebPkgFileIndex();
  110. };
  111. class APT_HIDDEN debDscFileIndex : public pkgIndexFile
  112. {
  113. private:
  114. void * const d;
  115. std::string DscFile;
  116. public:
  117. virtual const Type *GetType() const APT_CONST;
  118. virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
  119. virtual bool Exists() const APT_OVERRIDE;
  120. virtual bool HasPackages() const APT_OVERRIDE {return false;};
  121. virtual unsigned long Size() const APT_OVERRIDE;
  122. virtual std::string Describe(bool /*Short*/) const APT_OVERRIDE {
  123. return DscFile;
  124. };
  125. debDscFileIndex(std::string &DscFile);
  126. virtual ~debDscFileIndex();
  127. };
  128. class APT_HIDDEN debDebianSourceDirIndex : public debDscFileIndex
  129. {
  130. public:
  131. virtual const Type *GetType() const APT_CONST;
  132. };
  133. #endif