debrecords.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. protected:
  24. pkgTagSection Section;
  25. public:
  26. // These refer to the archive file for the Version
  27. virtual std::string FileName();
  28. virtual std::string SourcePkg();
  29. virtual std::string SourceVer();
  30. virtual HashStringList Hashes() const;
  31. // These are some general stats about the package
  32. virtual std::string Maintainer();
  33. virtual std::string ShortDesc(std::string const &lang);
  34. virtual std::string LongDesc(std::string const &lang);
  35. virtual std::string Name();
  36. virtual std::string Homepage();
  37. // An arbitrary custom field
  38. virtual std::string RecordField(const char *fieldName);
  39. virtual void GetRec(const char *&Start,const char *&Stop);
  40. debRecordParserBase() : Parser() {}
  41. virtual ~debRecordParserBase();
  42. };
  43. class APT_HIDDEN debRecordParser : public debRecordParserBase
  44. {
  45. protected:
  46. FileFd File;
  47. pkgTagFile Tags;
  48. virtual bool Jump(pkgCache::VerFileIterator const &Ver);
  49. virtual bool Jump(pkgCache::DescFileIterator const &Desc);
  50. public:
  51. debRecordParser(std::string FileName,pkgCache &Cache);
  52. virtual ~debRecordParser();
  53. };
  54. // custom record parser that reads deb files directly
  55. class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase
  56. {
  57. std::string debFileName;
  58. std::string controlContent;
  59. APT_HIDDEN bool LoadContent();
  60. protected:
  61. // single file files, so no jumping whatsoever
  62. bool Jump(pkgCache::VerFileIterator const &) { return LoadContent(); }
  63. bool Jump(pkgCache::DescFileIterator const &) { return LoadContent(); }
  64. public:
  65. virtual std::string FileName() { return debFileName; }
  66. debDebFileRecordParser(std::string FileName)
  67. : debRecordParserBase(), debFileName(FileName) {};
  68. };
  69. #endif