pkgcachegen.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgcachegen.h,v 1.15 1999/05/23 22:55:54 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 MMap;
  25. class pkgCacheGenerator
  26. {
  27. private:
  28. pkgCache::StringItem *UniqHash[26];
  29. public:
  30. class ListParser;
  31. friend ListParser;
  32. protected:
  33. DynamicMMap &Map;
  34. pkgCache Cache;
  35. OpProgress &Progress;
  36. string PkgFileName;
  37. pkgCache::PackageFile *CurrentFile;
  38. bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
  39. bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
  40. unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
  41. unsigned long WriteUniqString(const char *S,unsigned int Size);
  42. inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());};
  43. public:
  44. bool SelectFile(string File,unsigned long Flags = 0);
  45. bool MergeList(ListParser &List);
  46. inline pkgCache &GetCache() {return Cache;};
  47. inline pkgCache::PkgFileIterator GetCurFile()
  48. {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
  49. pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress);
  50. ~pkgCacheGenerator();
  51. };
  52. bool pkgSrcCacheCheck(pkgSourceList &List);
  53. bool pkgPkgCacheCheck(string CacheFile);
  54. bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress);
  55. MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress);
  56. // This is the abstract package list parser class.
  57. class pkgCacheGenerator::ListParser
  58. {
  59. pkgCacheGenerator *Owner;
  60. friend pkgCacheGenerator;
  61. // Some cache items
  62. pkgCache::VerIterator OldDepVer;
  63. __apt_ptrloc *OldDepLast;
  64. protected:
  65. inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
  66. inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
  67. inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
  68. inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
  69. bool NewDepends(pkgCache::VerIterator Ver,string Package,
  70. string Version,unsigned int Op,
  71. unsigned int Type);
  72. bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
  73. public:
  74. // These all operate against the current section
  75. virtual string Package() = 0;
  76. virtual string Version() = 0;
  77. virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
  78. virtual unsigned short VersionHash() = 0;
  79. virtual bool UsePackage(pkgCache::PkgIterator Pkg,
  80. pkgCache::VerIterator Ver) = 0;
  81. virtual unsigned long Offset() = 0;
  82. virtual unsigned long Size() = 0;
  83. virtual bool Step() = 0;
  84. virtual ~ListParser() {};
  85. };
  86. #endif