pkgrecords.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <string>
  18. #include <vector>
  19. class pkgRecords /*{{{*/
  20. {
  21. public:
  22. class Parser;
  23. private:
  24. /** \brief dpointer placeholder (for later in case we need it) */
  25. void *d;
  26. pkgCache &Cache;
  27. std::vector<Parser *>Files;
  28. public:
  29. // Lookup function
  30. Parser &Lookup(pkgCache::VerFileIterator const &Ver);
  31. Parser &Lookup(pkgCache::DescFileIterator const &Desc);
  32. // Construct destruct
  33. pkgRecords(pkgCache &Cache);
  34. ~pkgRecords();
  35. };
  36. /*}}}*/
  37. class pkgRecords::Parser /*{{{*/
  38. {
  39. protected:
  40. virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0;
  41. virtual bool Jump(pkgCache::DescFileIterator const &Desc) = 0;
  42. public:
  43. friend class pkgRecords;
  44. // These refer to the archive file for the Version
  45. virtual std::string FileName() {return std::string();};
  46. virtual std::string MD5Hash() {return std::string();};
  47. virtual std::string SHA1Hash() {return std::string();};
  48. virtual std::string SHA256Hash() {return std::string();};
  49. virtual std::string SHA512Hash() {return std::string();};
  50. virtual std::string SourcePkg() {return std::string();};
  51. virtual std::string SourceVer() {return std::string();};
  52. // These are some general stats about the package
  53. virtual std::string Maintainer() {return std::string();};
  54. virtual std::string ShortDesc() {return std::string();};
  55. virtual std::string LongDesc() {return std::string();};
  56. virtual std::string Name() {return std::string();};
  57. virtual std::string Homepage() {return std::string();}
  58. // An arbitrary custom field
  59. virtual std::string RecordField(const char * /*fieldName*/) { return std::string();};
  60. // The record in binary form
  61. virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};
  62. virtual ~Parser() {};
  63. };
  64. /*}}}*/
  65. #endif