apt 2.9.14 commandline package manager

deblistparser.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Debian Package List Parser - This implements the abstract parser
6 interface for Debian package files
7
8 ##################################################################### */
9 /*}}}*/
10#ifndef PKGLIB_DEBLISTPARSER_H
11#define PKGLIB_DEBLISTPARSER_H
12
13#include <apt-pkg/macros.h>
14#include <apt-pkg/pkgcache.h>
15#include <apt-pkg/pkgcachegen.h>
16#include <apt-pkg/tagfile.h>
17#ifdef APT_COMPILING_APT
18#include <apt-pkg/tagfile-keys.h>
19#endif
20
21#include <string>
22#include <vector>
23
24
25 class FileFd;
26
27 class APT_HIDDEN debListParser : public pkgCacheListParser
28{
29 public:
30
31 // Parser Helper
32 struct WordList
33 {
34 std::string_view Str;
35 unsigned char Val;
36 };
37
38 private:
39 std::vector<std::string> forceEssential;
40 std::vector<std::string> forceImportant;
41 std::string MD5Buffer;
42 std::string myArch;
43
44 protected:
45 pkgTagFile Tags;
46 pkgTagSection Section;
47 map_filesize_t iOffset;
48
49 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
50 bool ParseDepends(pkgCache::VerIterator &Ver, pkgTagSection::Key Key,
51 unsigned int Type);
52 bool ParseProvides(pkgCache::VerIterator &Ver);
53
54 APT_HIDDEN static bool GrabWord(std::string_view Word,const WordList *List,unsigned char &Out);
55 APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
56
57 public:
58
59 APT_PUBLIC static unsigned char GetPrio(std::string Str);
60
61 // These all operate against the current section
62 virtual std::string Package() APT_OVERRIDE;
63 virtual bool ArchitectureAll() APT_OVERRIDE;
64 virtual std::string_view Architecture() APT_OVERRIDE;
65 virtual std::string_view Version() APT_OVERRIDE;
66 virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
67 virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
68 virtual std::string_view Description_md5() APT_OVERRIDE;
69 virtual uint32_t VersionHash() APT_OVERRIDE;
70 virtual bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
71 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
72 pkgCache::VerIterator &Ver) APT_OVERRIDE;
73 virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
74 virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
75
76 virtual bool Step() APT_OVERRIDE;
77
78 APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
79 std::string &Package, std::string &Ver, unsigned int &Op,
80 bool const &ParseArchFlags = false, bool const &StripMultiArch = true,
81 bool const &ParseRestrictionsList = false,
82 std::string const &Arch = "");
83
84 APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
85 std::string_view &Package,
86 std::string_view &Ver, unsigned int &Op,
87 bool const ParseArchFlags = false, bool StripMultiArch = true,
88 bool const ParseRestrictionsList = false,
89 std::string Arch = "");
90
91 APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
92
93 explicit debListParser(FileFd *File);
94 virtual ~debListParser();
95
96#ifdef APT_COMPILING_APT
97 std::string_view SHA256() const
98 {
99 return Section.Find(pkgTagSection::Key::SHA256);
100 }
101#endif
102};
103
104 class APT_HIDDEN debDebFileParser : public debListParser
105{
106 private:
107 std::string DebFile;
108
109 public:
110 debDebFileParser(FileFd *File, std::string const &DebFile);
111 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
112 pkgCache::VerIterator &Ver) APT_OVERRIDE;
113};
114
115 class APT_HIDDEN debTranslationsParser : public debListParser
116{
117 public:
118 // a translation can never be a real package
119 virtual std::string_view Architecture() APT_OVERRIDE { return ""; }
120 virtual std::string_view Version() APT_OVERRIDE { return ""; }
121
122 explicit debTranslationsParser(FileFd *File)
123 : debListParser(File) {};
124};
125
126 class APT_HIDDEN debStatusListParser : public debListParser
127{
128 public:
129 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE;
130 explicit debStatusListParser(FileFd *File)
131 : debListParser(File) {};
132};
133#endif
FileFd
Definition fileutl.h:42
debDebFileParser
Definition deblistparser.h:105
debListParser
Definition deblistparser.h:28
debStatusListParser
Definition deblistparser.h:127
debTranslationsParser
Definition deblistparser.h:116
pkgCacheListParser
Definition pkgcachegen.h:177
pkgCache::PkgIterator
Definition cacheiterators.h:147
pkgCache::VerIterator
Definition cacheiterators.h:193
pkgCache
Definition pkgcache.h:126
pkgTagFile
Definition tagfile.h:191
pkgTagSection
Definition tagfile.h:45
pkgcache.h
pkgCache - Structure definitions for the cache file
debListParser::WordList
Definition deblistparser.h:33