pkgcachegen.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgcachegen.h,v 1.11 1998/12/14 02:23:47 jgg Exp $
  4. /* ######################################################################
  5. Package Cache Generator - Generator for the cache structure.
  6. This builds the cache structure from the abstract package list parser.
  7. Each archive source has it's own list parser that is instantiated by
  8. the caller to provide data for the generator.
  9. Parts of the cache are created by this generator class while other
  10. parts are created by the list parser. The list parser is responsible
  11. for creating version, depends and provides structures, and some of
  12. their contents
  13. ##################################################################### */
  14. /*}}}*/
  15. // Header section: pkglib
  16. #ifndef PKGLIB_PKGCACHEGEN_H
  17. #define PKGLIB_PKGCACHEGEN_H
  18. #ifdef __GNUG__
  19. #pragma interface "apt-pkg/pkgcachegen.h"
  20. #endif
  21. #include <apt-pkg/pkgcache.h>
  22. class pkgSourceList;
  23. class OpProgress;
  24. class pkgCacheGenerator
  25. {
  26. public:
  27. class ListParser;
  28. friend ListParser;
  29. protected:
  30. DynamicMMap &Map;
  31. pkgCache Cache;
  32. OpProgress &Progress;
  33. string PkgFileName;
  34. pkgCache::PackageFile *CurrentFile;
  35. bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
  36. bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
  37. unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
  38. unsigned long WriteUniqString(const char *S,unsigned int Size);
  39. inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
  40. public:
  41. bool SelectFile(string File,unsigned long Flags = 0);
  42. bool MergeList(ListParser &List);
  43. inline pkgCache &GetCache() {return Cache;};
  44. inline pkgCache::PkgFileIterator GetCurFile()
  45. {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
  46. pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress);
  47. ~pkgCacheGenerator();
  48. };
  49. bool pkgSrcCacheCheck(pkgSourceList &List);
  50. bool pkgPkgCacheCheck(string CacheFile);
  51. bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress);
  52. // This is the abstract package list parser class.
  53. class pkgCacheGenerator::ListParser
  54. {
  55. pkgCacheGenerator *Owner;
  56. friend pkgCacheGenerator;
  57. protected:
  58. inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
  59. inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
  60. inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
  61. inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
  62. bool NewDepends(pkgCache::VerIterator Ver,string Package,
  63. string Version,unsigned int Op,
  64. unsigned int Type);
  65. bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
  66. public:
  67. // These all operate against the current section
  68. virtual string Package() = 0;
  69. virtual string Version() = 0;
  70. virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
  71. virtual bool UsePackage(pkgCache::PkgIterator Pkg,
  72. pkgCache::VerIterator Ver) = 0;
  73. virtual unsigned long Offset() = 0;
  74. virtual unsigned long Size() = 0;
  75. virtual bool Step() = 0;
  76. virtual ~ListParser() {};
  77. };
  78. #endif