debrecords.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Homepage() APT_OVERRIDE;
  38. // An arbitrary custom field
  39. virtual std::string RecordField(const char *fieldName) APT_OVERRIDE;
  40. virtual void GetRec(const char *&Start,const char *&Stop) APT_OVERRIDE;
  41. debRecordParserBase();
  42. virtual ~debRecordParserBase();
  43. };
  44. class APT_HIDDEN debRecordParser : public debRecordParserBase
  45. {
  46. void * const d;
  47. protected:
  48. FileFd File;
  49. pkgTagFile Tags;
  50. virtual bool Jump(pkgCache::VerFileIterator const &Ver) APT_OVERRIDE;
  51. virtual bool Jump(pkgCache::DescFileIterator const &Desc) APT_OVERRIDE;
  52. public:
  53. debRecordParser(std::string FileName,pkgCache &Cache);
  54. virtual ~debRecordParser();
  55. };
  56. // custom record parser that reads deb files directly
  57. class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase
  58. {
  59. void * const d;
  60. std::string debFileName;
  61. std::string controlContent;
  62. APT_HIDDEN bool LoadContent();
  63. protected:
  64. // single file files, so no jumping whatsoever
  65. bool Jump(pkgCache::VerFileIterator const &) APT_OVERRIDE;
  66. bool Jump(pkgCache::DescFileIterator const &) APT_OVERRIDE;
  67. public:
  68. virtual std::string FileName() APT_OVERRIDE;
  69. debDebFileRecordParser(std::string FileName);
  70. virtual ~debDebFileRecordParser();
  71. };
  72. #endif