apt 3.0.3
commandline package manager
pkgrecords.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Package Records - Allows access to complete package description records
6 directly from the file.
7
8 The package record system abstracts the actual parsing of the
9 package files. This is different than the generators parser in that
10 it is used to access information not generate information. No
11 information touched by the generator should be parable from here as
12 it can always be retrieved directly from the cache.
13
14 ##################################################################### */
15 /*}}}*/
16#ifndef PKGLIB_PKGRECORDS_H
17#define PKGLIB_PKGRECORDS_H
18
19#include <apt-pkg/hashes.h>
20#include <apt-pkg/macros.h>
21#include <apt-pkg/pkgcache.h>
22
23#include <memory>
24#include <string>
25#include <vector>
26
27class APT_PUBLIC pkgRecords /*{{{*/
28{
29 public:
30 class Parser;
31
32 private:
34 void * const d;
35
36 pkgCache &Cache;
37 std::vector<std::unique_ptr<Parser>>Files;
38
39 public:
40 // Lookup function
41 Parser &Lookup(pkgCache::VerFileIterator const &Ver);
42 Parser &Lookup(pkgCache::DescFileIterator const &Desc);
43
44 // Construct destruct
45 explicit pkgRecords(pkgCache &Cache);
46 virtual ~pkgRecords();
47};
48 /*}}}*/
49class APT_PUBLIC pkgRecords::Parser /*{{{*/
50{
51 protected:
52
53 virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0;
54 virtual bool Jump(pkgCache::DescFileIterator const &Desc) = 0;
55
56 public:
57 friend class pkgRecords;
58
59 // These refer to the archive file for the Version
60 virtual std::string FileName() {return std::string();};
61 virtual std::string SourcePkg() {return std::string();};
62 virtual std::string SourceVer() {return std::string();};
63
70 virtual HashStringList Hashes() const { return HashStringList(); };
71
72 // These are some general stats about the package
73 virtual std::string Maintainer() {return std::string();};
78 virtual std::string ShortDesc(std::string const &/*lang*/) {return std::string();};
86 virtual std::string LongDesc(std::string const &/*lang*/) {return std::string();};
87 std::string ShortDesc() {return ShortDesc("");};
88 std::string LongDesc() {return LongDesc("");};
89
90 virtual std::string Name() {return std::string();};
91 virtual std::string Homepage() {return std::string();}
92
93 // An arbitrary custom field
94 virtual std::string RecordField(const char * /*fieldName*/) { return std::string();};
95
96 // The record in binary form
97 virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};
98
99 Parser();
100 virtual ~Parser();
101
102 private:
103 void * const d;
104 APT_HIDDEN std::string GetHashFromHashes(char const * const type) const
105 {
106 HashStringList const hashes = Hashes();
107 HashString const * const hs = hashes.find(type);
108 return hs != NULL ? hs->HashValue() : "";
109 };
110};
111 /*}}}*/
112#endif
Definition hashes.h:79
HashString const * find(char const *const type) const
Definition hashes.cc:192
Definition hashes.h:33
Definition hashes.h:184
Definition cacheiterators.h:47
Definition pkgrecords.h:28
virtual std::string LongDesc(std::string const &)
Definition pkgrecords.h:86
virtual std::string ShortDesc(std::string const &)
Definition pkgrecords.h:78
virtual HashStringList Hashes() const
Definition pkgrecords.h:70
pkgCache - Structure definitions for the cache file