apt 2.9.8 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#include <apt-pkg/string_view.h>
24
25
26 class FileFd;
27
28 class APT_HIDDEN debListParser : public pkgCacheListParser
29{
30 public:
31
32 // Parser Helper
33 struct WordList
34 {
35 APT::StringView Str;
36 unsigned char Val;
37 };
38
39 private:
40 std::vector<std::string> forceEssential;
41 std::vector<std::string> forceImportant;
42 std::string MD5Buffer;
43 std::string myArch;
44
45 protected:
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(APT::StringView 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 virtual std::string Package() APT_OVERRIDE;
64 virtual bool ArchitectureAll() APT_OVERRIDE;
65 virtual APT::StringView Architecture() APT_OVERRIDE;
66 virtual APT::StringView Version() APT_OVERRIDE;
67 virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
68 virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
69 virtual APT::StringView Description_md5() APT_OVERRIDE;
70 virtual uint32_t VersionHash() APT_OVERRIDE;
71 virtual bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
72 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
73 pkgCache::VerIterator &Ver) APT_OVERRIDE;
74 virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
75 virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
76
77 virtual bool Step() APT_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 APT::StringView &Package,
87 APT::StringView &Ver, unsigned int &Op,
88 bool const ParseArchFlags = false, bool StripMultiArch = true,
89 bool const 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 virtual ~debListParser();
96
97#ifdef APT_COMPILING_APT
98 APT::StringView SHA256() const
99 {
100 return Section.Find(pkgTagSection::Key::SHA256);
101 }
102#endif
103};
104
105 class APT_HIDDEN debDebFileParser : public debListParser
106{
107 private:
108 std::string DebFile;
109
110 public:
111 debDebFileParser(FileFd *File, std::string const &DebFile);
112 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
113 pkgCache::VerIterator &Ver) APT_OVERRIDE;
114};
115
116 class APT_HIDDEN debTranslationsParser : public debListParser
117{
118 public:
119 // a translation can never be a real package
120 virtual APT::StringView Architecture() APT_OVERRIDE { return ""; }
121 virtual APT::StringView Version() APT_OVERRIDE { return ""; }
122
123 explicit debTranslationsParser(FileFd *File)
124 : debListParser(File) {};
125};
126
127 class APT_HIDDEN debStatusListParser : public debListParser
128{
129 public:
130 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE;
131 explicit debStatusListParser(FileFd *File)
132 : debListParser(File) {};
133};
134#endif
APT::StringView
Simple subset of std::string_view from C++17.
Definition string_view.h:27
FileFd
Definition fileutl.h:41
debDebFileParser
Definition deblistparser.h:106
debListParser
Definition deblistparser.h:29
debStatusListParser
Definition deblistparser.h:128
debTranslationsParser
Definition deblistparser.h:117
pkgCacheListParser
Definition pkgcachegen.h:178
pkgCache::PkgIterator
Definition cacheiterators.h:147
pkgCache::VerIterator
Definition cacheiterators.h:193
pkgCache
Definition pkgcache.h:126
pkgTagFile
Definition tagfile.h:185
pkgTagSection
Definition tagfile.h:45
pkgcache.h
pkgCache - Structure definitions for the cache file
debListParser::WordList
Definition deblistparser.h:34