pkgrecords.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgrecords.h,v 1.6 2001/03/13 06:51:46 jgg Exp $
  4. /* ######################################################################
  5. Package Records - Allows access to complete package description records
  6. directly from the file.
  7. The package record system abstracts the actual parsing of the
  8. package files. This is different than the generators parser in that
  9. it is used to access information not generate information. No
  10. information touched by the generator should be parable from here as
  11. it can always be retreived directly from the cache.
  12. ##################################################################### */
  13. /*}}}*/
  14. #ifndef PKGLIB_PKGRECORDS_H
  15. #define PKGLIB_PKGRECORDS_H
  16. #include <apt-pkg/pkgcache.h>
  17. #include <vector>
  18. class pkgRecords /*{{{*/
  19. {
  20. public:
  21. class Parser;
  22. private:
  23. /** \brief dpointer placeholder (for later in case we need it) */
  24. void *d;
  25. pkgCache &Cache;
  26. std::vector<Parser *>Files;
  27. public:
  28. // Lookup function
  29. Parser &Lookup(pkgCache::VerFileIterator const &Ver);
  30. Parser &Lookup(pkgCache::DescFileIterator const &Desc);
  31. // Construct destruct
  32. pkgRecords(pkgCache &Cache);
  33. ~pkgRecords();
  34. };
  35. /*}}}*/
  36. class pkgRecords::Parser /*{{{*/
  37. {
  38. protected:
  39. virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0;
  40. virtual bool Jump(pkgCache::DescFileIterator const &Desc) = 0;
  41. public:
  42. friend class pkgRecords;
  43. // These refer to the archive file for the Version
  44. virtual string FileName() {return string();};
  45. virtual string MD5Hash() {return string();};
  46. virtual string SHA1Hash() {return string();};
  47. virtual string SHA256Hash() {return string();};
  48. virtual string SHA512Hash() {return string();};
  49. virtual string SourcePkg() {return string();};
  50. virtual string SourceVer() {return string();};
  51. // These are some general stats about the package
  52. virtual string Maintainer() {return string();};
  53. virtual string ShortDesc() {return string();};
  54. virtual string LongDesc() {return string();};
  55. virtual string Name() {return string();};
  56. virtual string Homepage() {return string();}
  57. // An arbitrary custom field
  58. virtual string RecordField(const char *fieldName) { return string();};
  59. // The record in binary form
  60. virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};
  61. virtual ~Parser() {};
  62. };
  63. /*}}}*/
  64. #endif