srcrecords.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. unsigned long Size;
  29. std::string Path;
  30. std::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. std::string Package;
  43. std::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 const &Off) = 0;
  51. virtual unsigned long Offset() = 0;
  52. virtual std::string AsStr() = 0;
  53. virtual std::string Package() const = 0;
  54. virtual std::string Version() const = 0;
  55. virtual std::string Maintainer() const = 0;
  56. virtual std::string Section() const = 0;
  57. virtual const char **Binaries() = 0; // Ownership does not transfer
  58. //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
  59. virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
  60. static const char *BuildDepType(unsigned char const &Type) APT_PURE;
  61. virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
  62. Parser(const pkgIndexFile *Index) : iIndex(Index) {};
  63. virtual ~Parser() {};
  64. };
  65. private:
  66. /** \brief dpointer placeholder (for later in case we need it) */
  67. void *d;
  68. // The list of files and the current parser pointer
  69. std::vector<Parser*> Files;
  70. std::vector<Parser *>::iterator Current;
  71. public:
  72. // Reset the search
  73. bool Restart();
  74. // Step to the next SourcePackage and return pointer to the
  75. // next SourceRecord. The pointer is owned by libapt.
  76. const Parser* Step();
  77. // Locate a package by name and return pointer to the Parser.
  78. // The pointer is owned by libapt.
  79. Parser* Find(const char *Package,bool const &SrcOnly = false);
  80. pkgSrcRecords(pkgSourceList &List);
  81. virtual ~pkgSrcRecords();
  82. };
  83. #endif