1 // -*- mode: cpp; mode: fold -*-
3 // $Id: deblistparser.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
4 /* ######################################################################
6 Debian Package List Parser - This implements the abstract parser
7 interface for Debian package files
9 ##################################################################### */
11 #ifndef PKGLIB_DEBLISTPARSER_H
12 #define PKGLIB_DEBLISTPARSER_H
14 #include <apt-pkg/pkgcachegen.h>
15 #include <apt-pkg/tagfile.h>
16 #include <apt-pkg/md5.h>
17 #include <apt-pkg/pkgcache.h>
18 #include <apt-pkg/macros.h>
22 #ifdef APT_PKG_EXPOSE_STRING_VIEW
23 #include <apt-pkg/string_view.h>
26 #ifndef APT_8_CLEANER_HEADERS
27 #include <apt-pkg/indexfile.h>
32 class APT_HIDDEN debListParser
: public pkgCacheListParser
36 #ifdef APT_PKG_EXPOSE_STRING_VIEW
46 std::vector
<std::string
> forceEssential
;
47 std::vector
<std::string
> forceImportant
;
48 std::string MD5Buffer
;
52 pkgTagSection Section
;
53 map_filesize_t iOffset
;
55 virtual bool ParseStatus(pkgCache::PkgIterator
&Pkg
,pkgCache::VerIterator
&Ver
);
56 bool ParseDepends(pkgCache::VerIterator
&Ver
, pkgTagSection::Key Key
,
58 bool ParseProvides(pkgCache::VerIterator
&Ver
);
60 #ifdef APT_PKG_EXPOSE_STRING_VIEW
61 APT_HIDDEN
static bool GrabWord(APT::StringView Word
,const WordList
*List
,unsigned char &Out
);
63 APT_HIDDEN
unsigned char ParseMultiArch(bool const showErrors
);
67 APT_PUBLIC
static unsigned char GetPrio(std::string Str
);
69 // These all operate against the current section
70 virtual std::string
Package() APT_OVERRIDE
;
71 virtual bool ArchitectureAll() APT_OVERRIDE
;
72 #ifdef APT_PKG_EXPOSE_STRING_VIEW
73 virtual APT::StringView
Architecture() APT_OVERRIDE
;
74 virtual APT::StringView
Version() APT_OVERRIDE
;
76 virtual bool NewVersion(pkgCache::VerIterator
&Ver
) APT_OVERRIDE
;
77 virtual std::vector
<std::string
> AvailableDescriptionLanguages() APT_OVERRIDE
;
78 #ifdef APT_PKG_EXPOSE_STRING_VIEW
79 virtual APT::StringView
Description_md5() APT_OVERRIDE
;
81 virtual unsigned short VersionHash() APT_OVERRIDE
;
82 virtual bool SameVersion(unsigned short const Hash
, pkgCache::VerIterator
const &Ver
) APT_OVERRIDE
;
83 virtual bool UsePackage(pkgCache::PkgIterator
&Pkg
,
84 pkgCache::VerIterator
&Ver
) APT_OVERRIDE
;
85 virtual map_filesize_t
Offset() APT_OVERRIDE
{return iOffset
;};
86 virtual map_filesize_t
Size() APT_OVERRIDE
{return Section
.size();};
88 virtual bool Step() APT_OVERRIDE
;
90 bool LoadReleaseInfo(pkgCache::RlsFileIterator
&FileI
,FileFd
&File
,
91 std::string
const §ion
);
93 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
94 std::string
&Package
,std::string
&Ver
,unsigned int &Op
);
95 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
96 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
97 bool const &ParseArchFlags
);
98 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
99 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
100 bool const &ParseArchFlags
, bool const &StripMultiArch
);
101 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
102 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
103 bool const &ParseArchFlags
, bool const &StripMultiArch
,
104 bool const &ParseRestrictionsList
);
106 #ifdef APT_PKG_EXPOSE_STRING_VIEW
107 APT_HIDDEN
static const char *ParseDepends(const char *Start
,const char *Stop
,
108 APT::StringView
&Package
,
109 APT::StringView
&Ver
,unsigned int &Op
,
110 bool const ParseArchFlags
= false, bool StripMultiArch
= true,
111 bool const ParseRestrictionsList
= false);
114 APT_PUBLIC
static const char *ConvertRelation(const char *I
,unsigned int &Op
);
116 debListParser(FileFd
*File
);
117 virtual ~debListParser();
120 class APT_HIDDEN debDebFileParser
: public debListParser
126 debDebFileParser(FileFd
*File
, std::string
const &DebFile
);
127 virtual bool UsePackage(pkgCache::PkgIterator
&Pkg
,
128 pkgCache::VerIterator
&Ver
) APT_OVERRIDE
;
131 class APT_HIDDEN debTranslationsParser
: public debListParser
134 #ifdef APT_PKG_EXPOSE_STRING_VIEW
135 // a translation can never be a real package
136 virtual APT::StringView
Architecture() APT_OVERRIDE
{ return ""; }
137 virtual APT::StringView
Version() APT_OVERRIDE
{ return ""; }
140 debTranslationsParser(FileFd
*File
)
141 : debListParser(File
) {};
144 class APT_HIDDEN debStatusListParser
: public debListParser
147 virtual bool ParseStatus(pkgCache::PkgIterator
&Pkg
,pkgCache::VerIterator
&Ver
);
148 debStatusListParser(FileFd
*File
)
149 : debListParser(File
) {};