indexfile.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 <string>
  20. #include <apt-pkg/pkgcache.h>
  21. #include <apt-pkg/srcrecords.h>
  22. #include <apt-pkg/pkgrecords.h>
  23. #include <apt-pkg/macros.h>
  24. #ifndef APT_8_CLEANER_HEADERS
  25. using std::string;
  26. #endif
  27. class pkgAcquire;
  28. class pkgCacheGenerator;
  29. class OpProgress;
  30. class pkgIndexFile
  31. {
  32. protected:
  33. bool Trusted;
  34. public:
  35. class Type
  36. {
  37. public:
  38. // Global list of Items supported
  39. static Type **GlobalList;
  40. static unsigned long GlobalListLen;
  41. static Type *GetType(const char *Type);
  42. const char *Label;
  43. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
  44. Type();
  45. virtual ~Type() {};
  46. };
  47. virtual const Type *GetType() const = 0;
  48. // Return descriptive strings of various sorts
  49. virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
  50. virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
  51. pkgSrcRecords::File const &File) const;
  52. virtual std::string Describe(bool Short = false) const = 0;
  53. // Interface for acquire
  54. virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();};
  55. // Interface for the record parsers
  56. virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
  57. // Interface for the Cache Generator
  58. virtual bool Exists() const = 0;
  59. virtual bool HasPackages() const = 0;
  60. virtual unsigned long Size() const = 0;
  61. virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* Prog) const { return false; };
  62. __deprecated virtual bool Merge(pkgCacheGenerator &Gen, OpProgress &Prog) const
  63. { return Merge(Gen, &Prog); };
  64. virtual bool MergeFileProvides(pkgCacheGenerator &Gen,OpProgress* Prog) const {return true;};
  65. __deprecated virtual bool MergeFileProvides(pkgCacheGenerator &Gen, OpProgress &Prog) const
  66. {return MergeFileProvides(Gen, &Prog);};
  67. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  68. static bool TranslationsAvailable();
  69. static bool CheckLanguageCode(const char *Lang);
  70. static std::string LanguageCode();
  71. bool IsTrusted() const { return Trusted; };
  72. pkgIndexFile(bool Trusted): Trusted(Trusted) {};
  73. virtual ~pkgIndexFile() {};
  74. };
  75. #endif