apt: apt-pkg/deb/deblistparser.h Source File

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