]> git.saurik.com Git - apt.git/blob - apt-pkg/deb/deblistparser.h
Bug #807012 also involves package dependencies :/.
[apt.git] / apt-pkg / deb / deblistparser.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: deblistparser.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
4 /* ######################################################################
5
6 Debian Package List Parser - This implements the abstract parser
7 interface for Debian package files
8
9 ##################################################################### */
10 /*}}}*/
11 #ifndef PKGLIB_DEBLISTPARSER_H
12 #define PKGLIB_DEBLISTPARSER_H
13
14 #include <apt-pkg/pkgcachegen.h>
15 #include <apt-pkg/tagfile.h>
16 #include <apt-pkg/md5.h>
17 #include <apt-pkg/pkgcache.h>
18 #include <apt-pkg/macros.h>
19
20 #include <string>
21 #include <vector>
22 #ifdef APT_PKG_EXPOSE_STRING_VIEW
23 #include <apt-pkg/string_view.h>
24 #endif
25
26 #ifndef APT_8_CLEANER_HEADERS
27 #include <apt-pkg/indexfile.h>
28 #endif
29
30 class FileFd;
31
32 class APT_HIDDEN debListParser : public pkgCacheListParser
33 {
34 public:
35
36 #ifdef APT_PKG_EXPOSE_STRING_VIEW
37 // Parser Helper
38 struct WordList
39 {
40 APT::StringView Str;
41 unsigned char Val;
42 };
43 #endif
44
45 private:
46 std::vector<std::string> forceEssential;
47 std::vector<std::string> forceImportant;
48 std::string MD5Buffer;
49
50 protected:
51 pkgTagFile Tags;
52 pkgTagSection Section;
53 map_filesize_t iOffset;
54
55 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
56 bool ParseDepends(pkgCache::VerIterator &Ver, pkgTagSection::Key Key,
57 unsigned int Type);
58 bool ParseProvides(pkgCache::VerIterator &Ver);
59 bool ParseTag(pkgCache::VerIterator &Ver);
60
61 #ifdef APT_PKG_EXPOSE_STRING_VIEW
62 APT_HIDDEN static bool GrabWord(APT::StringView Word,const WordList *List,unsigned char &Out);
63 #endif
64 APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
65
66 public:
67
68 APT_PUBLIC static unsigned char GetPrio(std::string Str);
69
70 // These all operate against the current section
71 virtual std::string Package() APT_OVERRIDE;
72 virtual bool ArchitectureAll() APT_OVERRIDE;
73 #ifdef APT_PKG_EXPOSE_STRING_VIEW
74 virtual APT::StringView Architecture() APT_OVERRIDE;
75 virtual APT::StringView Version() APT_OVERRIDE;
76 #endif
77 virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
78 virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
79 #ifdef APT_PKG_EXPOSE_STRING_VIEW
80 virtual APT::StringView Description_md5() APT_OVERRIDE;
81 #endif
82 virtual unsigned short VersionHash() APT_OVERRIDE;
83 virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
84 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
85 pkgCache::VerIterator &Ver) APT_OVERRIDE;
86 virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
87 virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
88
89 virtual bool Step() APT_OVERRIDE;
90
91 bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
92 std::string const &section);
93
94 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
95 std::string &Package,std::string &Ver,unsigned int &Op);
96 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
97 std::string &Package,std::string &Ver,unsigned int &Op,
98 bool const &ParseArchFlags);
99 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
100 std::string &Package,std::string &Ver,unsigned int &Op,
101 bool const &ParseArchFlags, bool const &StripMultiArch);
102 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
103 std::string &Package,std::string &Ver,unsigned int &Op,
104 bool const &ParseArchFlags, bool const &StripMultiArch,
105 bool const &ParseRestrictionsList);
106
107 #ifdef APT_PKG_EXPOSE_STRING_VIEW
108 APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop,
109 APT::StringView &Package,
110 APT::StringView &Ver,unsigned int &Op,
111 bool const ParseArchFlags = false, bool StripMultiArch = true,
112 bool const ParseRestrictionsList = false);
113 #endif
114
115 APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
116
117 debListParser(FileFd *File);
118 virtual ~debListParser();
119 };
120
121 class APT_HIDDEN debDebFileParser : public debListParser
122 {
123 private:
124 std::string DebFile;
125
126 public:
127 debDebFileParser(FileFd *File, std::string const &DebFile);
128 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
129 pkgCache::VerIterator &Ver) APT_OVERRIDE;
130 };
131
132 class APT_HIDDEN debTranslationsParser : public debListParser
133 {
134 public:
135 #ifdef APT_PKG_EXPOSE_STRING_VIEW
136 // a translation can never be a real package
137 virtual APT::StringView Architecture() APT_OVERRIDE { return ""; }
138 virtual APT::StringView Version() APT_OVERRIDE { return ""; }
139 #endif
140
141 debTranslationsParser(FileFd *File)
142 : debListParser(File) {};
143 };
144
145 class APT_HIDDEN debStatusListParser : public debListParser
146 {
147 public:
148 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
149 debStatusListParser(FileFd *File)
150 : debListParser(File) {};
151 };
152 #endif