srcrecords.h 2.4 KB

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