]> git.saurik.com Git - apt.git/blob - apt-pkg/deb/deblistparser.h
43ce0cfd36f14403a4483329ca333677fa5f8b67
[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
49 protected:
50 pkgTagFile Tags;
51 pkgTagSection Section;
52 map_filesize_t iOffset;
53
54 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
55 bool ParseDepends(pkgCache::VerIterator &Ver, pkgTagSection::Key Key,
56 unsigned int Type);
57 bool ParseProvides(pkgCache::VerIterator &Ver);
58
59 #ifdef APT_PKG_EXPOSE_STRING_VIEW
60 APT_HIDDEN static bool GrabWord(APT::StringView Word,const WordList *List,unsigned char &Out);
61 #endif
62 APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
63
64 public:
65
66 APT_PUBLIC static unsigned char GetPrio(std::string Str);
67
68 // These all operate against the current section
69 virtual std::string Package() APT_OVERRIDE;
70 virtual bool ArchitectureAll() APT_OVERRIDE;
71 #ifdef APT_PKG_EXPOSE_STRING_VIEW
72 virtual APT::StringView Architecture() APT_OVERRIDE;
73 virtual APT::StringView Version() APT_OVERRIDE;
74 #endif
75 virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
76 virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
77 virtual MD5SumValue Description_md5() APT_OVERRIDE;
78 virtual unsigned short VersionHash() APT_OVERRIDE;
79 virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
80 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
81 pkgCache::VerIterator &Ver) APT_OVERRIDE;
82 virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
83 virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
84
85 virtual bool Step() APT_OVERRIDE;
86
87 bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
88 std::string const &section);
89
90 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
91 std::string &Package,std::string &Ver,unsigned int &Op);
92 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
93 std::string &Package,std::string &Ver,unsigned int &Op,
94 bool const &ParseArchFlags);
95 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
96 std::string &Package,std::string &Ver,unsigned int &Op,
97 bool const &ParseArchFlags, bool const &StripMultiArch);
98 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
99 std::string &Package,std::string &Ver,unsigned int &Op,
100 bool const &ParseArchFlags, bool const &StripMultiArch,
101 bool const &ParseRestrictionsList);
102
103 #ifdef APT_PKG_EXPOSE_STRING_VIEW
104 APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop,
105 APT::StringView &Package,
106 APT::StringView &Ver,unsigned int &Op,
107 bool const ParseArchFlags = false, bool StripMultiArch = true,
108 bool const ParseRestrictionsList = false);
109 #endif
110
111 APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
112
113 debListParser(FileFd *File);
114 virtual ~debListParser();
115 };
116
117 class APT_HIDDEN debDebFileParser : public debListParser
118 {
119 private:
120 std::string DebFile;
121
122 public:
123 debDebFileParser(FileFd *File, std::string const &DebFile);
124 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
125 pkgCache::VerIterator &Ver) APT_OVERRIDE;
126 };
127
128 class APT_HIDDEN debTranslationsParser : public debListParser
129 {
130 public:
131 #ifdef APT_PKG_EXPOSE_STRING_VIEW
132 // a translation can never be a real package
133 virtual APT::StringView Architecture() APT_OVERRIDE { return ""; }
134 virtual APT::StringView Version() APT_OVERRIDE { return ""; }
135 #endif
136
137 debTranslationsParser(FileFd *File)
138 : debListParser(File) {};
139 };
140
141 class APT_HIDDEN debStatusListParser : public debListParser
142 {
143 public:
144 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
145 debStatusListParser(FileFd *File)
146 : debListParser(File) {};
147 };
148 #endif