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

apt 3.3.3 commandline package manager

debrecords.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Debian Package Records - Parser for debian package records
6
7 This provides display-type parsing for the Packages file. This is
8 different than the list parser which provides cache generation
9 services. There should be no overlap between these two.
10
11 ##################################################################### */
12 /*}}}*/
13#ifndef PKGLIB_DEBRECORDS_H
14#define PKGLIB_DEBRECORDS_H
15
16#include <apt-pkg/fileutl.h>
17#include <apt-pkg/pkgcache.h>
18#include <apt-pkg/pkgrecords.h>
19#include <apt-pkg/tagfile.h>
20
21#include <string>
22
23
24 class APT_HIDDEN debRecordParserBase : public pkgRecords::Parser
25{
26 void * const d;
27 protected:
28 pkgTagSection Section;
29
30 public:
31 // These refer to the archive file for the Version
32 std::string FileName() override;
33 std::string SourcePkg() override;
34 std::string SourceVer() override;
35
36 [[nodiscard]] HashStringList Hashes() const override;
37
38 // These are some general stats about the package
39 std::string Maintainer() override;
40 std::string ShortDesc(std::string const &lang) override;
41 std::string LongDesc(std::string const &lang) override;
42 std::string Name() override;
43 std::string Homepage() override;
44
45 // An arbitrary custom field
46 std::string RecordField(const char *fieldName) override;
47
48 void GetRec(const char *&Start, const char *&Stop) override;
49
50 debRecordParserBase();
51 ~debRecordParserBase() override;
52};
53
54 class APT_HIDDEN debRecordParser : public debRecordParserBase
55{
56 void * const d;
57 protected:
58 FileFd File;
59 pkgTagFile Tags;
60
61 bool Jump(pkgCache::VerFileIterator const &Ver) override;
62 bool Jump(pkgCache::DescFileIterator const &Desc) override;
63
64 public:
65 debRecordParser(std::string FileName,pkgCache &Cache);
66 ~debRecordParser() override;
67};
68
69// custom record parser that reads deb files directly
70 class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase
71{
72 void * const d;
73 std::string debFileName;
74 std::string controlContent;
75
76 APT_HIDDEN bool LoadContent();
77 protected:
78 // single file files, so no jumping whatsoever
79 bool Jump(pkgCache::VerFileIterator const &/*Ver*/) override;
80 bool Jump(pkgCache::DescFileIterator const & /*Desc*/) override;
81
82 public:
83 std::string FileName() override;
84
85 explicit debDebFileRecordParser(std::string FileName);
86 ~debDebFileRecordParser() override;
87};
88
89#endif
FileFd
Definition fileutl.h:43
HashStringList
Definition hashes.h:79
pkgCache::DescFileIterator
Definition cacheiterators.h:548
pkgCache::VerFileIterator
Definition cacheiterators.h:530
pkgCache
Definition pkgcache.h:126
pkgRecords::Parser
Definition pkgrecords.h:50
pkgRecords::Parser::LongDesc
virtual std::string LongDesc(std::string const &)
Definition pkgrecords.h:86
pkgRecords::Parser::ShortDesc
virtual std::string ShortDesc(std::string const &)
Definition pkgrecords.h:78
pkgRecords::Parser::Hashes
virtual HashStringList Hashes() const
Definition pkgrecords.h:70
pkgTagFile
Definition tagfile.h:186
pkgTagSection
Definition tagfile.h:46
pkgcache.h
pkgCache - Structure definitions for the cache file