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