debrecords.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: debrecords.h,v 1.8 2001/03/13 06:51:46 jgg Exp $
  4. /* ######################################################################
  5. Debian Package Records - Parser for debian package records
  6. This provides display-type parsing for the Packages file. This is
  7. different than the the list parser which provides cache generation
  8. services. There should be no overlap between these two.
  9. ##################################################################### */
  10. /*}}}*/
  11. #ifndef PKGLIB_DEBRECORDS_H
  12. #define PKGLIB_DEBRECORDS_H
  13. #include <apt-pkg/pkgrecords.h>
  14. #include <apt-pkg/tagfile.h>
  15. #include <apt-pkg/fileutl.h>
  16. #include <apt-pkg/pkgcache.h>
  17. #include <string>
  18. #ifndef APT_8_CLEANER_HEADERS
  19. #include <apt-pkg/indexfile.h>
  20. #endif
  21. class APT_HIDDEN debRecordParserBase : public pkgRecords::Parser
  22. {
  23. void * const d;
  24. protected:
  25. pkgTagSection Section;
  26. public:
  27. // These refer to the archive file for the Version
  28. virtual std::string FileName() APT_OVERRIDE;
  29. virtual std::string SourcePkg() APT_OVERRIDE;
  30. virtual std::string SourceVer() APT_OVERRIDE;
  31. virtual HashStringList Hashes() const APT_OVERRIDE;
  32. // These are some general stats about the package
  33. virtual std::string Maintainer() APT_OVERRIDE;
  34. virtual std::string ShortDesc(std::string const &lang) APT_OVERRIDE;
  35. virtual std::string LongDesc(std::string const &lang) APT_OVERRIDE;
  36. virtual std::string Name() APT_OVERRIDE;
  37. virtual std::string Display() APT_OVERRIDE;
  38. virtual std::string Homepage() APT_OVERRIDE;
  39. // An arbitrary custom field
  40. virtual std::string RecordField(const char *fieldName) APT_OVERRIDE;
  41. virtual void GetRec(const char *&Start,const char *&Stop) APT_OVERRIDE;
  42. virtual bool Find(const char *Tag,const char *&Start, const char *&End) APT_OVERRIDE;
  43. debRecordParserBase();
  44. virtual ~debRecordParserBase();
  45. };
  46. class APT_HIDDEN debRecordParser : public debRecordParserBase
  47. {
  48. void * const d;
  49. protected:
  50. FileFd File;
  51. pkgTagFile Tags;
  52. virtual bool Jump(pkgCache::VerFileIterator const &Ver) APT_OVERRIDE;
  53. virtual bool Jump(pkgCache::DescFileIterator const &Desc) APT_OVERRIDE;
  54. public:
  55. debRecordParser(std::string FileName,pkgCache &Cache);
  56. virtual ~debRecordParser();
  57. };
  58. // custom record parser that reads deb files directly
  59. class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase
  60. {
  61. void * const d;
  62. std::string debFileName;
  63. std::string controlContent;
  64. APT_HIDDEN bool LoadContent();
  65. protected:
  66. // single file files, so no jumping whatsoever
  67. bool Jump(pkgCache::VerFileIterator const &) APT_OVERRIDE;
  68. bool Jump(pkgCache::DescFileIterator const &) APT_OVERRIDE;
  69. public:
  70. virtual std::string FileName() APT_OVERRIDE;
  71. debDebFileRecordParser(std::string FileName);
  72. virtual ~debDebFileRecordParser();
  73. };
  74. #endif