indexfile.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. Bianry index files decribing 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 acess the underlying representation.
  15. ##################################################################### */
  16. /*}}}*/
  17. #ifndef PKGLIB_INDEXFILE_H
  18. #define PKGLIB_INDEXFILE_H
  19. #ifdef __GNUG__
  20. #pragma interface "apt-pkg/indexfile.h"
  21. #endif
  22. #include <string>
  23. #include <apt-pkg/pkgcache.h>
  24. #include <apt-pkg/srcrecords.h>
  25. #include <apt-pkg/pkgrecords.h>
  26. using std::string;
  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. };
  46. virtual const Type *GetType() const = 0;
  47. // Return descriptive strings of various sorts
  48. virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
  49. virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
  50. pkgSrcRecords::File const &File) const;
  51. virtual string Describe(bool Short = false) const = 0;
  52. // Interface for acquire
  53. virtual string ArchiveURI(string /*File*/) const {return string();};
  54. // Interface for the record parsers
  55. virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
  56. // Interface for the Cache Generator
  57. virtual bool Exists() const = 0;
  58. virtual bool HasPackages() const = 0;
  59. virtual unsigned long Size() const = 0;
  60. virtual bool Merge(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return false;};
  61. virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
  62. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  63. static bool UseTranslation();
  64. static bool CheckLanguageCode(const char *Lang);
  65. static string LanguageCode();
  66. bool IsTrusted() const { return Trusted; };
  67. pkgIndexFile(bool Trusted): Trusted(Trusted) {};
  68. virtual ~pkgIndexFile() {};
  69. };
  70. #endif