]>
Commit | Line | Data |
---|---|---|
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 | /** \brief dpointer placeholder (for later in case we need it) */ | |
47 | void * const d; | |
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 | #ifdef APT_PKG_EXPOSE_STRING_VIEW | |
56 | bool ParseDepends(pkgCache::VerIterator &Ver, APT::StringView Tag, | |
57 | unsigned int Type); | |
58 | #endif | |
59 | bool ParseProvides(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 | virtual MD5SumValue Description_md5() APT_OVERRIDE; | |
80 | virtual unsigned short VersionHash() APT_OVERRIDE; | |
81 | virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE; | |
82 | virtual bool UsePackage(pkgCache::PkgIterator &Pkg, | |
83 | pkgCache::VerIterator &Ver) APT_OVERRIDE; | |
84 | virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;}; | |
85 | virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();}; | |
86 | ||
87 | virtual bool Step() APT_OVERRIDE; | |
88 | ||
89 | bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File, | |
90 | std::string const §ion); | |
91 | ||
92 | APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop, | |
93 | std::string &Package,std::string &Ver,unsigned int &Op); | |
94 | APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop, | |
95 | std::string &Package,std::string &Ver,unsigned int &Op, | |
96 | bool const &ParseArchFlags); | |
97 | APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop, | |
98 | std::string &Package,std::string &Ver,unsigned int &Op, | |
99 | bool const &ParseArchFlags, bool const &StripMultiArch); | |
100 | APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop, | |
101 | std::string &Package,std::string &Ver,unsigned int &Op, | |
102 | bool const &ParseArchFlags, bool const &StripMultiArch, | |
103 | bool const &ParseRestrictionsList); | |
104 | ||
105 | #ifdef APT_PKG_EXPOSE_STRING_VIEW | |
106 | APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop, | |
107 | APT::StringView &Package, | |
108 | APT::StringView &Ver,unsigned int &Op, | |
109 | bool const ParseArchFlags = false, bool StripMultiArch = true, | |
110 | bool const ParseRestrictionsList = false); | |
111 | #endif | |
112 | ||
113 | APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op); | |
114 | ||
115 | debListParser(FileFd *File); | |
116 | virtual ~debListParser(); | |
117 | }; | |
118 | ||
119 | class APT_HIDDEN debDebFileParser : public debListParser | |
120 | { | |
121 | private: | |
122 | std::string DebFile; | |
123 | ||
124 | public: | |
125 | debDebFileParser(FileFd *File, std::string const &DebFile); | |
126 | virtual bool UsePackage(pkgCache::PkgIterator &Pkg, | |
127 | pkgCache::VerIterator &Ver) APT_OVERRIDE; | |
128 | }; | |
129 | ||
130 | class APT_HIDDEN debTranslationsParser : public debListParser | |
131 | { | |
132 | public: | |
133 | #ifdef APT_PKG_EXPOSE_STRING_VIEW | |
134 | // a translation can never be a real package | |
135 | virtual APT::StringView Architecture() APT_OVERRIDE { return ""; } | |
136 | virtual APT::StringView Version() APT_OVERRIDE { return ""; } | |
137 | #endif | |
138 | ||
139 | debTranslationsParser(FileFd *File) | |
140 | : debListParser(File) {}; | |
141 | }; | |
142 | ||
143 | class APT_HIDDEN debStatusListParser : public debListParser | |
144 | { | |
145 | public: | |
146 | virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver); | |
147 | debStatusListParser(FileFd *File) | |
148 | : debListParser(File) {}; | |
149 | }; | |
150 | #endif |