You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

130 lines
4.2 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: deblistparser.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
  4. /* ######################################################################
  5. Debian Package List Parser - This implements the abstract parser
  6. interface for Debian package files
  7. ##################################################################### */
  8. /*}}}*/
  9. #ifndef PKGLIB_DEBLISTPARSER_H
  10. #define PKGLIB_DEBLISTPARSER_H
  11. #include <apt-pkg/pkgcachegen.h>
  12. #include <apt-pkg/tagfile.h>
  13. #include <apt-pkg/md5.h>
  14. #include <apt-pkg/pkgcache.h>
  15. #include <apt-pkg/macros.h>
  16. #include <string>
  17. #include <vector>
  18. #ifndef APT_8_CLEANER_HEADERS
  19. #include <apt-pkg/indexfile.h>
  20. #endif
  21. class FileFd;
  22. class APT_HIDDEN debListParser : public pkgCacheListParser
  23. {
  24. public:
  25. // Parser Helper
  26. struct WordList
  27. {
  28. const char *Str;
  29. unsigned char Val;
  30. };
  31. private:
  32. /** \brief dpointer placeholder (for later in case we need it) */
  33. void * const d;
  34. protected:
  35. pkgTagFile Tags;
  36. pkgTagSection Section;
  37. map_filesize_t iOffset;
  38. virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
  39. bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
  40. unsigned int Type);
  41. bool ParseProvides(pkgCache::VerIterator &Ver);
  42. static bool GrabWord(std::string Word,WordList *List,unsigned char &Out);
  43. APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
  44. public:
  45. APT_PUBLIC static unsigned char GetPrio(std::string Str);
  46. // These all operate against the current section
  47. virtual std::string Package() APT_OVERRIDE;
  48. virtual std::string Architecture() APT_OVERRIDE;
  49. virtual bool ArchitectureAll() APT_OVERRIDE;
  50. virtual std::string Version() APT_OVERRIDE;
  51. virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
  52. virtual std::string Description(std::string const &lang) APT_OVERRIDE;
  53. virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
  54. virtual MD5SumValue Description_md5() APT_OVERRIDE;
  55. virtual unsigned short VersionHash() APT_OVERRIDE;
  56. virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
  57. virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
  58. pkgCache::VerIterator &Ver) APT_OVERRIDE;
  59. virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
  60. virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
  61. virtual bool Step() APT_OVERRIDE;
  62. bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
  63. std::string const &section);
  64. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  65. std::string &Package,std::string &Ver,unsigned int &Op);
  66. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  67. std::string &Package,std::string &Ver,unsigned int &Op,
  68. bool const &ParseArchFlags);
  69. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  70. std::string &Package,std::string &Ver,unsigned int &Op,
  71. bool const &ParseArchFlags, bool const &StripMultiArch);
  72. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  73. std::string &Package,std::string &Ver,unsigned int &Op,
  74. bool const &ParseArchFlags, bool const &StripMultiArch,
  75. bool const &ParseRestrictionsList);
  76. APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
  77. debListParser(FileFd *File);
  78. virtual ~debListParser();
  79. };
  80. class APT_HIDDEN debDebFileParser : public debListParser
  81. {
  82. private:
  83. std::string DebFile;
  84. public:
  85. debDebFileParser(FileFd *File, std::string const &DebFile);
  86. virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
  87. pkgCache::VerIterator &Ver) APT_OVERRIDE;
  88. };
  89. class APT_HIDDEN debTranslationsParser : public debListParser
  90. {
  91. public:
  92. // a translation can never be a real package
  93. virtual std::string Architecture() APT_OVERRIDE { return ""; }
  94. virtual std::string Version() APT_OVERRIDE { return ""; }
  95. debTranslationsParser(FileFd *File)
  96. : debListParser(File) {};
  97. };
  98. class APT_HIDDEN debStatusListParser : public debListParser
  99. {
  100. public:
  101. virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
  102. debStatusListParser(FileFd *File)
  103. : debListParser(File) {};
  104. };
  105. #endif