srcrecords.h 2.7 KB

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