apt: apt-pkg/pkgrecords.h Source File

apt 2.7.5 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 <string>
24#include <vector>
25
26 class APT_PUBLIC pkgRecords /*{{{*/
27{
28 public:
29 class Parser;
30
31 private:
33 void * const d;
34
35 pkgCache &Cache;
36 std::vector<Parser *>Files;
37
38 public:
39 // Lookup function
40 Parser &Lookup(pkgCache::VerFileIterator const &Ver);
41 Parser &Lookup(pkgCache::DescFileIterator const &Desc);
42
43 // Construct destruct
44 explicit pkgRecords(pkgCache &Cache);
45 virtual ~pkgRecords();
46};
47 /*}}}*/
48class APT_PUBLIC pkgRecords::Parser /*{{{*/
49{
50 protected:
51
52 virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0;
53 virtual bool Jump(pkgCache::DescFileIterator const &Desc) = 0;
54
55 public:
56 friend class pkgRecords;
57
58 // These refer to the archive file for the Version
59 virtual std::string FileName() {return std::string();};
60 virtual std::string SourcePkg() {return std::string();};
61 virtual std::string SourceVer() {return std::string();};
62
69 virtual HashStringList Hashes() const { return HashStringList(); };
70
71 // These are some general stats about the package
72 virtual std::string Maintainer() {return std::string();};
77 virtual std::string ShortDesc(std::string const &/*lang*/) {return std::string();};
85 virtual std::string LongDesc(std::string const &/*lang*/) {return std::string();};
86 std::string ShortDesc() {return ShortDesc("");};
87 std::string LongDesc() {return LongDesc("");};
88
89 virtual std::string Name() {return std::string();};
90 virtual std::string Homepage() {return std::string();}
91
92 // An arbitrary custom field
93 virtual std::string RecordField(const char * /*fieldName*/) { return std::string();};
94
95 // The record in binary form
96 virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;};
97
98 Parser();
99 virtual ~Parser();
100
101 private:
102 void * const d;
103 APT_HIDDEN std::string GetHashFromHashes(char const * const type) const
104 {
105 HashStringList const hashes = Hashes();
106 HashString const * const hs = hashes.find(type);
107 return hs != NULL ? hs->HashValue() : "";
108 };
109};
110 /*}}}*/
111#endif
HashStringList
Definition hashes.h:79
HashStringList::find
HashString const * find(char const *const type) const
Definition hashes.cc:202
HashString
Definition hashes.h:33
Hashes
Definition hashes.h:184
pkgCache
Definition cacheiterators.h:47
pkgRecords
Definition pkgrecords.h:27
pkgRecords::LongDesc
virtual std::string LongDesc(std::string const &)
Definition pkgrecords.h:85
pkgRecords::ShortDesc
virtual std::string ShortDesc(std::string const &)
Definition pkgrecords.h:77
pkgRecords::Hashes
virtual HashStringList Hashes() const
Definition pkgrecords.h:69
pkgcache.h
pkgCache - Structure definitions for the cache file