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

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