pkgcachegen.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgcachegen.h,v 1.1 1998/07/02 02:58:13 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. ##################################################################### */
  8. /*}}}*/
  9. // Header section: pkglib
  10. #ifndef PKGLIB_PKGCACHEGEN_H
  11. #define PKGLIB_PKGCACHEGEN_H
  12. #include <pkglib/pkgcache.h>
  13. class pkgCacheGenerator
  14. {
  15. public:
  16. class ListParser;
  17. protected:
  18. DynamicMMap &Map;
  19. pkgCache Cache;
  20. string PkgFileName;
  21. pkgCache::PackageFile *CurrentFile;
  22. bool NewPackage(pkgCache::PkgIterator Pkg,string Pkg);
  23. bool NewFileVer(pkgCache::VerIterator Ver,ListParser &List);
  24. unsigned long NewVersion(pkgCache::VerIterator &Ver,unsigned long Next);
  25. public:
  26. // This is the abstract package list parser class.
  27. class ListParser
  28. {
  29. pkgCacheGenerator *Owner;
  30. friend pkgCacheGenerator;
  31. protected:
  32. inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
  33. inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
  34. public:
  35. // These all operate against the current section
  36. virtual string Package() = 0;
  37. virtual string Version() = 0;
  38. virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
  39. virtual bool NewPackage(pkgCache::PkgIterator Pkg) = 0;
  40. virtual bool UsePackage(pkgCache::PkgIterator Pkg) = 0;
  41. virtual bool Step() = 0;
  42. };
  43. friend ListParser;
  44. bool SelectFile(string File,unsigned long Flags = 0);
  45. bool MergeList(ListParser &List);
  46. pkgCacheGenerator(DynamicMMap &Map);
  47. ~pkgCacheGenerator();
  48. };
  49. #endif