deblistparser.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  19. #include <apt-pkg/string_view.h>
  20. #endif
  21. #ifndef APT_8_CLEANER_HEADERS
  22. #include <apt-pkg/indexfile.h>
  23. #endif
  24. class FileFd;
  25. class APT_HIDDEN debListParser : public pkgCacheListParser
  26. {
  27. public:
  28. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  29. // Parser Helper
  30. struct WordList
  31. {
  32. APT::StringView Str;
  33. unsigned char Val;
  34. };
  35. #endif
  36. private:
  37. std::vector<std::string> forceEssential;
  38. std::vector<std::string> forceImportant;
  39. std::string MD5Buffer;
  40. protected:
  41. pkgTagFile Tags;
  42. pkgTagSection Section;
  43. map_filesize_t iOffset;
  44. virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
  45. bool ParseDepends(pkgCache::VerIterator &Ver, pkgTagSection::Key Key,
  46. unsigned int Type);
  47. bool ParseProvides(pkgCache::VerIterator &Ver);
  48. bool ParseTag(pkgCache::VerIterator &Ver);
  49. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  50. APT_HIDDEN static bool GrabWord(APT::StringView Word,const WordList *List,unsigned char &Out);
  51. #endif
  52. APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
  53. public:
  54. APT_PUBLIC static unsigned char GetPrio(std::string Str);
  55. // These all operate against the current section
  56. virtual std::string Package() APT_OVERRIDE;
  57. virtual bool ArchitectureAll() APT_OVERRIDE;
  58. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  59. virtual APT::StringView Architecture() APT_OVERRIDE;
  60. virtual APT::StringView Version() APT_OVERRIDE;
  61. #endif
  62. virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
  63. virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
  64. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  65. virtual APT::StringView Description_md5() APT_OVERRIDE;
  66. #endif
  67. virtual unsigned short VersionHash() APT_OVERRIDE;
  68. virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
  69. virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
  70. pkgCache::VerIterator &Ver) APT_OVERRIDE;
  71. virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
  72. virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
  73. virtual bool Step() APT_OVERRIDE;
  74. bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
  75. std::string const &section);
  76. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  77. std::string &Package,std::string &Ver,unsigned int &Op);
  78. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  79. std::string &Package,std::string &Ver,unsigned int &Op,
  80. bool const &ParseArchFlags);
  81. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  82. std::string &Package,std::string &Ver,unsigned int &Op,
  83. bool const &ParseArchFlags, bool const &StripMultiArch);
  84. APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
  85. std::string &Package,std::string &Ver,unsigned int &Op,
  86. bool const &ParseArchFlags, bool const &StripMultiArch,
  87. bool const &ParseRestrictionsList);
  88. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  89. APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop,
  90. APT::StringView &Package,
  91. APT::StringView &Ver,unsigned int &Op,
  92. bool const ParseArchFlags = false, bool StripMultiArch = true,
  93. bool const ParseRestrictionsList = false);
  94. #endif
  95. APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
  96. debListParser(FileFd *File);
  97. virtual ~debListParser();
  98. };
  99. class APT_HIDDEN debDebFileParser : public debListParser
  100. {
  101. private:
  102. std::string DebFile;
  103. public:
  104. debDebFileParser(FileFd *File, std::string const &DebFile);
  105. virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
  106. pkgCache::VerIterator &Ver) APT_OVERRIDE;
  107. };
  108. class APT_HIDDEN debTranslationsParser : public debListParser
  109. {
  110. public:
  111. #ifdef APT_PKG_EXPOSE_STRING_VIEW
  112. // a translation can never be a real package
  113. virtual APT::StringView Architecture() APT_OVERRIDE { return ""; }
  114. virtual APT::StringView Version() APT_OVERRIDE { return ""; }
  115. #endif
  116. debTranslationsParser(FileFd *File)
  117. : debListParser(File) {};
  118. };
  119. class APT_HIDDEN debStatusListParser : public debListParser
  120. {
  121. public:
  122. virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
  123. debStatusListParser(FileFd *File)
  124. : debListParser(File) {};
  125. };
  126. #endif