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 /** \brief dpointer placeholder (for later in case we need it) */
51 pkgTagSection Section
;
52 map_filesize_t iOffset
;
54 virtual bool ParseStatus(pkgCache::PkgIterator
&Pkg
,pkgCache::VerIterator
&Ver
);
55 #ifdef APT_PKG_EXPOSE_STRING_VIEW
56 bool ParseDepends(pkgCache::VerIterator
&Ver
, APT::StringView Tag
,
59 bool ParseProvides(pkgCache::VerIterator
&Ver
);
61 #ifdef APT_PKG_EXPOSE_STRING_VIEW
62 APT_HIDDEN
static bool GrabWord(APT::StringView Word
,const WordList
*List
,unsigned char &Out
);
64 APT_HIDDEN
unsigned char ParseMultiArch(bool const showErrors
);
68 APT_PUBLIC
static unsigned char GetPrio(std::string Str
);
70 // These all operate against the current section
71 virtual std::string
Package() APT_OVERRIDE
;
72 virtual std::string
Architecture() APT_OVERRIDE
;
73 virtual bool ArchitectureAll() APT_OVERRIDE
;
74 virtual std::string
Version() APT_OVERRIDE
;
75 virtual bool NewVersion(pkgCache::VerIterator
&Ver
) APT_OVERRIDE
;
76 virtual std::string
Description(std::string
const &lang
) APT_OVERRIDE
;
77 #ifdef APT_PKG_EXPOSE_STRING_VIEW
78 APT::StringView
Description(APT::StringView lang
);
80 virtual std::vector
<std::string
> AvailableDescriptionLanguages() APT_OVERRIDE
;
81 virtual MD5SumValue
Description_md5() APT_OVERRIDE
;
82 virtual unsigned short VersionHash() APT_OVERRIDE
;
83 virtual bool SameVersion(unsigned short const Hash
, pkgCache::VerIterator
const &Ver
) APT_OVERRIDE
;
84 virtual bool UsePackage(pkgCache::PkgIterator
&Pkg
,
85 pkgCache::VerIterator
&Ver
) APT_OVERRIDE
;
86 virtual map_filesize_t
Offset() APT_OVERRIDE
{return iOffset
;};
87 virtual map_filesize_t
Size() APT_OVERRIDE
{return Section
.size();};
89 virtual bool Step() APT_OVERRIDE
;
91 bool LoadReleaseInfo(pkgCache::RlsFileIterator
&FileI
,FileFd
&File
,
92 std::string
const §ion
);
94 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
95 std::string
&Package
,std::string
&Ver
,unsigned int &Op
);
96 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
97 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
98 bool const &ParseArchFlags
);
99 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
100 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
101 bool const &ParseArchFlags
, bool const &StripMultiArch
);
102 APT_PUBLIC
static const char *ParseDepends(const char *Start
,const char *Stop
,
103 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
104 bool const &ParseArchFlags
, bool const &StripMultiArch
,
105 bool const &ParseRestrictionsList
);
107 #ifdef APT_PKG_EXPOSE_STRING_VIEW
108 APT_HIDDEN
static const char *ParseDepends(const char *Start
,const char *Stop
,
109 APT::StringView
&Package
,
110 APT::StringView
&Ver
,unsigned int &Op
,
111 bool const ParseArchFlags
= false, bool StripMultiArch
= true,
112 bool const ParseRestrictionsList
= false);
115 APT_PUBLIC
static const char *ConvertRelation(const char *I
,unsigned int &Op
);
117 debListParser(FileFd
*File
);
118 virtual ~debListParser();
121 class APT_HIDDEN debDebFileParser
: public debListParser
127 debDebFileParser(FileFd
*File
, std::string
const &DebFile
);
128 virtual bool UsePackage(pkgCache::PkgIterator
&Pkg
,
129 pkgCache::VerIterator
&Ver
) APT_OVERRIDE
;
132 class APT_HIDDEN debTranslationsParser
: public debListParser
135 // a translation can never be a real package
136 virtual std::string
Architecture() APT_OVERRIDE
{ return ""; }
137 virtual std::string
Version() APT_OVERRIDE
{ return ""; }
139 debTranslationsParser(FileFd
*File
)
140 : debListParser(File
) {};
143 class APT_HIDDEN debStatusListParser
: public debListParser
146 virtual bool ParseStatus(pkgCache::PkgIterator
&Pkg
,pkgCache::VerIterator
&Ver
);
147 debStatusListParser(FileFd
*File
)
148 : debListParser(File
) {};