indexfile.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: indexfile.h,v 1.6.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. Index File - Abstraction for an index of archive/source file.
  6. There are 4 primary sorts of index files, all represented by this
  7. class:
  8. Binary index files
  9. Binary translation files
  10. Binary index files describing the local system
  11. Source index files
  12. They are all bundled together here, and the interfaces for
  13. sources.list, acquire, cache gen and record parsing all use this class
  14. to access the underlying representation.
  15. ##################################################################### */
  16. /*}}}*/
  17. #ifndef PKGLIB_INDEXFILE_H
  18. #define PKGLIB_INDEXFILE_H
  19. #include <apt-pkg/srcrecords.h>
  20. #include <apt-pkg/pkgrecords.h>
  21. #include <apt-pkg/pkgcache.h>
  22. #include <apt-pkg/cacheiterators.h>
  23. #include <apt-pkg/macros.h>
  24. #include <string>
  25. #ifndef APT_8_CLEANER_HEADERS
  26. using std::string;
  27. #endif
  28. #ifndef APT_10_CLEANER_HEADERS
  29. class pkgAcquire;
  30. #endif
  31. class pkgCacheGenerator;
  32. class OpProgress;
  33. class pkgIndexFile
  34. {
  35. protected:
  36. bool Trusted;
  37. public:
  38. class Type
  39. {
  40. public:
  41. // Global list of Items supported
  42. static Type **GlobalList;
  43. static unsigned long GlobalListLen;
  44. static Type *GetType(const char *Type) APT_PURE;
  45. const char *Label;
  46. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
  47. virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string /*File*/) const {return 0;};
  48. Type();
  49. virtual ~Type() {};
  50. };
  51. virtual const Type *GetType() const = 0;
  52. // Return descriptive strings of various sorts
  53. virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
  54. virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
  55. pkgSrcRecords::File const &File) const;
  56. virtual std::string Describe(bool Short = false) const = 0;
  57. // Interface for acquire
  58. virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();};
  59. // Interface for the record parsers
  60. virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
  61. // Interface for the Cache Generator
  62. virtual bool Exists() const = 0;
  63. virtual bool HasPackages() const = 0;
  64. virtual unsigned long Size() const = 0;
  65. virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* /*Prog*/) const { return false; };
  66. APT_DEPRECATED virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
  67. { return Merge(Gen, &Prog); };
  68. virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress* /*Prog*/) const {return true;};
  69. APT_DEPRECATED virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
  70. {return MergeFileProvides(Gen, &Prog);};
  71. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  72. static bool TranslationsAvailable();
  73. static bool CheckLanguageCode(const char *Lang);
  74. static std::string LanguageCode();
  75. bool IsTrusted() const { return Trusted; };
  76. pkgIndexFile(bool Trusted): Trusted(Trusted) {};
  77. virtual ~pkgIndexFile() {};
  78. };
  79. #endif