srcrecords.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: srcrecords.h,v 1.5 1999/10/18 03:44:39 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 AsStr() = 0;
  39. virtual string Package() = 0;
  40. virtual string Version() = 0;
  41. virtual string Maintainer() = 0;
  42. virtual string Section() = 0;
  43. virtual const char **Binaries() = 0;
  44. virtual bool Files(vector<pkgSrcRecords::File> &F) = 0;
  45. Parser(FileFd *File,pkgSourceList::const_iterator SrcItem) : File(File),
  46. SrcItem(SrcItem) {};
  47. virtual ~Parser() {delete File;};
  48. };
  49. private:
  50. // The list of files and the current parser pointer
  51. Parser **Files;
  52. Parser **Current;
  53. public:
  54. // Reset the search
  55. bool Restart();
  56. // Locate a package by name
  57. Parser *Find(const char *Package,bool SrcOnly = false);
  58. pkgSrcRecords(pkgSourceList &List);
  59. ~pkgSrcRecords();
  60. };
  61. #endif