srcrecords.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: srcrecords.h,v 1.4 1999/07/20 05:53:33 jgg Exp $
  4. /* ######################################################################
  5. Source Package Records - Allows access to source package records
  6. Parses and allows access to the list of source records and searching by
  7. source name on that list.
  8. ##################################################################### */
  9. /*}}}*/
  10. #ifndef PKGLIB_SRCRECORDS_H
  11. #define PKGLIB_SRCRECORDS_H
  12. #ifdef __GNUG__
  13. #pragma interface "apt-pkg/srcrecords.h"
  14. #endif
  15. #include <apt-pkg/fileutl.h>
  16. #include <apt-pkg/sourcelist.h>
  17. class pkgSrcRecords
  18. {
  19. public:
  20. // Describes a single file
  21. struct File
  22. {
  23. string MD5Hash;
  24. unsigned long Size;
  25. string Path;
  26. };
  27. // Abstract parser for each source record
  28. class Parser
  29. {
  30. FileFd *File;
  31. pkgSourceList::const_iterator SrcItem;
  32. public:
  33. inline pkgSourceList::const_iterator Source() const {return SrcItem;};
  34. virtual bool Restart() = 0;
  35. virtual bool Step() = 0;
  36. virtual bool Jump(unsigned long Off) = 0;
  37. virtual unsigned long Offset() = 0;
  38. virtual string Package() = 0;
  39. virtual string Version() = 0;
  40. virtual string Maintainer() = 0;
  41. virtual string Section() = 0;
  42. virtual const char **Binaries() = 0;
  43. virtual bool Files(vector<pkgSrcRecords::File> &F) = 0;
  44. Parser(FileFd *File,pkgSourceList::const_iterator SrcItem) : File(File),
  45. SrcItem(SrcItem) {};
  46. virtual ~Parser() {delete File;};
  47. };
  48. private:
  49. // The list of files and the current parser pointer
  50. Parser **Files;
  51. Parser **Current;
  52. public:
  53. // Reset the search
  54. bool Restart();
  55. // Locate a package by name
  56. Parser *Find(const char *Package,bool SrcOnly = false);
  57. pkgSrcRecords(pkgSourceList &List);
  58. ~pkgSrcRecords();
  59. };
  60. #endif