srcrecords.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #include <apt-pkg/macros.h>
  13. #include <string>
  14. #include <vector>
  15. #ifndef APT_8_CLEANER_HEADERS
  16. using std::string;
  17. using std::vector;
  18. #endif
  19. class pkgSourceList;
  20. class pkgIndexFile;
  21. class pkgSrcRecords
  22. {
  23. public:
  24. // Describes a single file
  25. struct File
  26. {
  27. std::string MD5Hash;
  28. std::string Hash;
  29. unsigned long Size;
  30. std::string Path;
  31. std::string Type;
  32. };
  33. // Abstract parser for each source record
  34. class Parser
  35. {
  36. protected:
  37. const pkgIndexFile *iIndex;
  38. public:
  39. enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
  40. BuildConflict=0x2,BuildConflictIndep=0x3};
  41. struct BuildDepRec
  42. {
  43. std::string Package;
  44. std::string Version;
  45. unsigned int Op;
  46. unsigned char Type;
  47. };
  48. inline const pkgIndexFile &Index() const {return *iIndex;};
  49. virtual bool Restart() = 0;
  50. virtual bool Step() = 0;
  51. virtual bool Jump(unsigned long const &Off) = 0;
  52. virtual unsigned long Offset() = 0;
  53. virtual std::string AsStr() = 0;
  54. virtual std::string Package() const = 0;
  55. virtual std::string Version() const = 0;
  56. virtual std::string Maintainer() const = 0;
  57. virtual std::string Section() const = 0;
  58. virtual const char **Binaries() = 0; // Ownership does not transfer
  59. //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
  60. virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
  61. static const char *BuildDepType(unsigned char const &Type) APT_PURE;
  62. virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
  63. Parser(const pkgIndexFile *Index) : iIndex(Index) {};
  64. virtual ~Parser() {};
  65. };
  66. private:
  67. /** \brief dpointer placeholder (for later in case we need it) */
  68. void *d;
  69. // The list of files and the current parser pointer
  70. std::vector<Parser*> Files;
  71. std::vector<Parser *>::iterator Current;
  72. public:
  73. // Reset the search
  74. bool Restart();
  75. // Locate a package by name
  76. Parser *Find(const char *Package,bool const &SrcOnly = false);
  77. pkgSrcRecords(pkgSourceList &List);
  78. virtual ~pkgSrcRecords();
  79. };
  80. #endif