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