srcrecords.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: srcrecords.h,v 1.6 2001/02/20 07:03:17 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 <string>
  16. #include <vector>
  17. class pkgSourceList;
  18. class pkgIndexFile;
  19. class pkgSrcRecords
  20. {
  21. public:
  22. // Describes a single file
  23. struct File
  24. {
  25. string MD5Hash;
  26. unsigned long Size;
  27. string Path;
  28. string Type;
  29. };
  30. // Abstract parser for each source record
  31. class Parser
  32. {
  33. protected:
  34. const pkgIndexFile *iIndex;
  35. public:
  36. enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
  37. BuildConflict=0x2,BuildConflictIndep=0x3};
  38. struct BuildDepRec
  39. {
  40. string Package;
  41. string Version;
  42. unsigned int Op;
  43. unsigned char Type;
  44. };
  45. inline const pkgIndexFile &Index() const {return *iIndex;};
  46. virtual bool Restart() = 0;
  47. virtual bool Step() = 0;
  48. virtual bool Jump(unsigned long Off) = 0;
  49. virtual unsigned long Offset() = 0;
  50. virtual string AsStr() = 0;
  51. virtual string Package() const = 0;
  52. virtual string Version() const = 0;
  53. virtual string Maintainer() const = 0;
  54. virtual string Section() const = 0;
  55. virtual const char **Binaries() = 0; // Ownership does not transfer
  56. virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps) = 0;
  57. static const char *BuildDepType(unsigned char Type);
  58. virtual bool Files(vector<pkgSrcRecords::File> &F) = 0;
  59. Parser(const pkgIndexFile *Index) : iIndex(Index) {};
  60. virtual ~Parser() {};
  61. };
  62. private:
  63. // The list of files and the current parser pointer
  64. Parser **Files;
  65. Parser **Current;
  66. public:
  67. // Reset the search
  68. bool Restart();
  69. // Locate a package by name
  70. Parser *Find(const char *Package,bool SrcOnly = false);
  71. pkgSrcRecords(pkgSourceList &List);
  72. ~pkgSrcRecords();
  73. };
  74. #endif