indexfile.h 2.7 KB

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