apt 2.9.25 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 std::string Package() override;
63 bool ArchitectureAll() override;
64 std::string_view Architecture() override;
65 std::string_view Version() override;
66 bool NewVersion(pkgCache::VerIterator &Ver) override;
67 std::vector<std::string> AvailableDescriptionLanguages() override;
68 std::string_view Description_md5() override;
69 uint32_t VersionHash() override;
70 bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver) override;
71 bool UsePackage(pkgCache::PkgIterator &Pkg,
72 pkgCache::VerIterator &Ver) override;
73 map_filesize_t Offset() override { return iOffset; };
74 map_filesize_t Size() override { return Section.size(); };
75
76 bool Step() 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#if APT_PKG_ABI <= 600
85 [[deprecated("Use std::string_view variant instead")]]
86 APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
87 APT::StringView &Package,
88 APT::StringView &Ver, unsigned int &Op,
89 bool ParseArchFlags = false, bool StripMultiArch = true,
90 bool ParseRestrictionsList = false,
91 std::string Arch = "");
92#endif
93 APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
94 std::string_view &Package,
95 std::string_view &Ver, unsigned int &Op,
96 bool ParseArchFlags = false, bool StripMultiArch = true,
97 bool ParseRestrictionsList = false,
98 std::string Arch = "");
99
100 APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
101
102 explicit debListParser(FileFd *File);
103 ~debListParser() override;
104
105#ifdef APT_COMPILING_APT
106 std::string_view SHA256() const
107 {
108 return Section.Find(pkgTagSection::Key::SHA256);
109 }
110#endif
111};
112
113 class APT_HIDDEN debDebFileParser : public debListParser
114{
115 private:
116 std::string DebFile;
117
118 public:
119 debDebFileParser(FileFd *File, std::string const &DebFile);
120 bool UsePackage(pkgCache::PkgIterator &Pkg,
121 pkgCache::VerIterator &Ver) override;
122};
123
124 class APT_HIDDEN debTranslationsParser : public debListParser
125{
126 public:
127 // a translation can never be a real package
128 std::string_view Architecture() override { return {}; }
129 std::string_view Version() override { return {}; }
130
131 explicit debTranslationsParser(FileFd *File)
132 : debListParser(File) {};
133};
134
135 class APT_HIDDEN debStatusListParser : public debListParser
136{
137 public:
138 bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) override;
139 explicit debStatusListParser(FileFd *File)
140 : debListParser(File) {};
141};
142#endif
FileFd
Definition fileutl.h:42
pkgCacheListParser::SameVersion
virtual bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver)
Definition pkgcachegen.cc:1265
pkgCache::PkgIterator
Definition cacheiterators.h:147
pkgCache::VerIterator
Definition cacheiterators.h:193
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