pkgcachegen.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgcachegen.h,v 1.3 1998/07/05 05:33:57 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. bool NewDepends(pkgCache::VerIterator Ver,string Package,
  39. string Version,unsigned int Op,
  40. unsigned int Type);
  41. bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
  42. public:
  43. // These all operate against the current section
  44. virtual string Package() = 0;
  45. virtual string Version() = 0;
  46. virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
  47. virtual bool UsePackage(pkgCache::PkgIterator Pkg,
  48. pkgCache::VerIterator Ver) = 0;
  49. virtual unsigned long Offset() = 0;
  50. virtual unsigned long Size() = 0;
  51. virtual bool Step() = 0;
  52. virtual ~ListParser() {};
  53. };
  54. friend ListParser;
  55. bool SelectFile(string File,unsigned long Flags = 0);
  56. bool MergeList(ListParser &List);
  57. pkgCacheGenerator(DynamicMMap &Map);
  58. ~pkgCacheGenerator();
  59. };
  60. #endif