pkgcachegen.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgcachegen.h,v 1.2 1998/07/04 05:57:38 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,string VerStr,unsigned long Next);
  25. unsigned long WriteUniqString(const char *S,unsigned int Size);
  26. inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
  27. public:
  28. // This is the abstract package list parser class.
  29. class ListParser
  30. {
  31. pkgCacheGenerator *Owner;
  32. friend pkgCacheGenerator;
  33. protected:
  34. inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
  35. inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
  36. inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
  37. inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
  38. public:
  39. // These all operate against the current section
  40. virtual string Package() = 0;
  41. virtual string Version() = 0;
  42. virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
  43. virtual bool NewPackage(pkgCache::PkgIterator Pkg) = 0;
  44. virtual bool UsePackage(pkgCache::PkgIterator Pkg,
  45. pkgCache::VerIterator Ver) = 0;
  46. virtual bool Step() = 0;
  47. virtual ~ListParser() {};
  48. };
  49. friend ListParser;
  50. bool SelectFile(string File,unsigned long Flags = 0);
  51. bool MergeList(ListParser &List);
  52. pkgCacheGenerator(DynamicMMap &Map);
  53. ~pkgCacheGenerator();
  54. };
  55. #endif