]> git.saurik.com Git - apt.git/blame - apt-pkg/deb/deblistparser.h
provide a constexpr char[] overload for APT::StringView
[apt.git] / apt-pkg / deb / deblistparser.h
CommitLineData
f55a958f
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
b2e465d6 3// $Id: deblistparser.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
f55a958f
AL
4/* ######################################################################
5
6 Debian Package List Parser - This implements the abstract parser
7 interface for Debian package files
8
9 ##################################################################### */
10 /*}}}*/
f55a958f
AL
11#ifndef PKGLIB_DEBLISTPARSER_H
12#define PKGLIB_DEBLISTPARSER_H
13
094a497d
AL
14#include <apt-pkg/pkgcachegen.h>
15#include <apt-pkg/tagfile.h>
453b82a3
DK
16#include <apt-pkg/md5.h>
17#include <apt-pkg/pkgcache.h>
ce62f1de 18#include <apt-pkg/macros.h>
453b82a3
DK
19
20#include <string>
21#include <vector>
eff0c22e
JAK
22#ifdef APT_PKG_EXPOSE_STRING_VIEW
23#include <apt-pkg/string_view.h>
24#endif
f55a958f 25
b9dadc24
DK
26#ifndef APT_8_CLEANER_HEADERS
27#include <apt-pkg/indexfile.h>
28#endif
29
453b82a3
DK
30class FileFd;
31
c9443c01 32class APT_HIDDEN debListParser : public pkgCacheListParser
f55a958f 33{
b2e465d6
AL
34 public:
35
f55a958f
AL
36 // Parser Helper
37 struct WordList
38 {
b2e465d6 39 const char *Str;
f55a958f
AL
40 unsigned char Val;
41 };
6d38011b 42
b2e465d6 43 private:
ff72bd0d 44 /** \brief dpointer placeholder (for later in case we need it) */
6c55f07a 45 void * const d;
6d38011b 46
36b8ebbb 47 protected:
b2e465d6
AL
48 pkgTagFile Tags;
49 pkgTagSection Section;
4ad8619b 50 map_filesize_t iOffset;
dcfa253f 51
6d38011b 52 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
e9a1e5f9
JAK
53#ifdef APT_PKG_EXPOSE_STRING_VIEW
54 bool ParseDepends(pkgCache::VerIterator &Ver, APT::StringView Tag,
dcb79bae 55 unsigned int Type);
e9a1e5f9 56#endif
32b9a14c 57 bool ParseProvides(pkgCache::VerIterator &Ver);
eff0c22e
JAK
58
59#ifdef APT_PKG_EXPOSE_STRING_VIEW
60 APT_HIDDEN static bool GrabWord(APT::StringView Word,const WordList *List,unsigned char &Out);
61#endif
0d29b9d4
MV
62 APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors);
63
f55a958f 64 public:
b2e465d6 65
dce45dbe 66 APT_PUBLIC static unsigned char GetPrio(std::string Str);
b2e465d6 67
f55a958f 68 // These all operate against the current section
3b302846
DK
69 virtual std::string Package() APT_OVERRIDE;
70 virtual std::string Architecture() APT_OVERRIDE;
71 virtual bool ArchitectureAll() APT_OVERRIDE;
72 virtual std::string Version() APT_OVERRIDE;
73 virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
74 virtual std::string Description(std::string const &lang) APT_OVERRIDE;
eff0c22e
JAK
75#ifdef APT_PKG_EXPOSE_STRING_VIEW
76 APT::StringView Description(APT::StringView lang);
77#endif
3b302846
DK
78 virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
79 virtual MD5SumValue Description_md5() APT_OVERRIDE;
80 virtual unsigned short VersionHash() APT_OVERRIDE;
3b302846 81 virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
32b9a14c 82 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
3b302846
DK
83 pkgCache::VerIterator &Ver) APT_OVERRIDE;
84 virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};
85 virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();};
f55a958f 86
3b302846 87 virtual bool Step() APT_OVERRIDE;
b07aeb1a
DK
88
89 bool LoadReleaseInfo(pkgCache::RlsFileIterator &FileI,FileFd &File,
90 std::string const &section);
565ded7b 91
dce45dbe 92 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
565ded7b 93 std::string &Package,std::string &Ver,unsigned int &Op);
dce45dbe 94 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
565ded7b
JS
95 std::string &Package,std::string &Ver,unsigned int &Op,
96 bool const &ParseArchFlags);
dce45dbe 97 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
565ded7b
JS
98 std::string &Package,std::string &Ver,unsigned int &Op,
99 bool const &ParseArchFlags, bool const &StripMultiArch);
dce45dbe 100 APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
565ded7b
JS
101 std::string &Package,std::string &Ver,unsigned int &Op,
102 bool const &ParseArchFlags, bool const &StripMultiArch,
103 bool const &ParseRestrictionsList);
104
eff0c22e
JAK
105#ifdef APT_PKG_EXPOSE_STRING_VIEW
106 APT_HIDDEN static const char *ParseDepends(const char *Start,const char *Stop,
107 APT::StringView &Package,
108 APT::StringView &Ver,unsigned int &Op,
109 bool const ParseArchFlags = false, bool StripMultiArch = true,
110 bool const ParseRestrictionsList = false);
111#endif
112
dce45dbe 113 APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
b2e465d6 114
7f8c0eed 115 debListParser(FileFd *File);
862bafea 116 virtual ~debListParser();
0d29b9d4 117};
e33dbfe5 118
dce45dbe 119class APT_HIDDEN debDebFileParser : public debListParser
0d29b9d4
MV
120{
121 private:
122 std::string DebFile;
123
124 public:
125 debDebFileParser(FileFd *File, std::string const &DebFile);
126 virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
3b302846 127 pkgCache::VerIterator &Ver) APT_OVERRIDE;
f55a958f
AL
128};
129
dce45dbe 130class APT_HIDDEN debTranslationsParser : public debListParser
bc1c9081
MV
131{
132 public:
133 // a translation can never be a real package
3b302846
DK
134 virtual std::string Architecture() APT_OVERRIDE { return ""; }
135 virtual std::string Version() APT_OVERRIDE { return ""; }
bc1c9081 136
7f8c0eed
DK
137 debTranslationsParser(FileFd *File)
138 : debListParser(File) {};
bc1c9081
MV
139};
140
1c73b0fc
JAK
141class APT_HIDDEN debStatusListParser : public debListParser
142{
143 public:
144 virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
145 debStatusListParser(FileFd *File)
146 : debListParser(File) {};
147};
f55a958f 148#endif