]>
Commit | Line | Data |
---|---|---|
f55ece0e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
a7c835af | 3 | // $Id: pkgrecords.h,v 1.6 2001/03/13 06:51:46 jgg Exp $ |
f55ece0e AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Records - Allows access to complete package description records | |
7 | directly from the file. | |
8 | ||
9 | The package record system abstracts the actual parsing of the | |
10 | package files. This is different than the generators parser in that | |
11 | it is used to access information not generate information. No | |
12 | information touched by the generator should be parable from here as | |
13 | it can always be retreived directly from the cache. | |
14 | ||
15 | ##################################################################### */ | |
16 | /*}}}*/ | |
f55ece0e AL |
17 | #ifndef PKGLIB_PKGRECORDS_H |
18 | #define PKGLIB_PKGRECORDS_H | |
19 | ||
f55ece0e | 20 | #include <apt-pkg/pkgcache.h> |
b3501edb DK |
21 | #include <apt-pkg/hashes.h> |
22 | #include <apt-pkg/macros.h> | |
453b82a3 DK |
23 | |
24 | #include <string> | |
30257943 | 25 | #include <vector> |
f55ece0e | 26 | |
92fcbfc1 | 27 | class pkgRecords /*{{{*/ |
f55ece0e AL |
28 | { |
29 | public: | |
30 | class Parser; | |
31 | ||
32 | private: | |
be9b62f7 MV |
33 | /** \brief dpointer placeholder (for later in case we need it) */ |
34 | void *d; | |
f55ece0e AL |
35 | |
36 | pkgCache &Cache; | |
30257943 MV |
37 | std::vector<Parser *>Files; |
38 | ||
be9b62f7 | 39 | public: |
f55ece0e | 40 | // Lookup function |
03e39e59 | 41 | Parser &Lookup(pkgCache::VerFileIterator const &Ver); |
a52f938b | 42 | Parser &Lookup(pkgCache::DescFileIterator const &Desc); |
03e39e59 | 43 | |
f55ece0e AL |
44 | // Construct destruct |
45 | pkgRecords(pkgCache &Cache); | |
46 | ~pkgRecords(); | |
47 | }; | |
92fcbfc1 DK |
48 | /*}}}*/ |
49 | class pkgRecords::Parser /*{{{*/ | |
f55ece0e | 50 | { |
7e798dd7 | 51 | protected: |
f55ece0e | 52 | |
03e39e59 | 53 | virtual bool Jump(pkgCache::VerFileIterator const &Ver) = 0; |
a52f938b | 54 | virtual bool Jump(pkgCache::DescFileIterator const &Desc) = 0; |
f55ece0e | 55 | |
7e798dd7 | 56 | public: |
b2e465d6 | 57 | friend class pkgRecords; |
7e798dd7 AL |
58 | |
59 | // These refer to the archive file for the Version | |
8f3ba4e8 | 60 | virtual std::string FileName() {return std::string();}; |
8f3ba4e8 DK |
61 | virtual std::string SourcePkg() {return std::string();}; |
62 | virtual std::string SourceVer() {return std::string();}; | |
b2e465d6 | 63 | |
b3501edb DK |
64 | /** return all known hashes in this record. |
65 | * | |
66 | * For authentication proposes packages come with hashsums which | |
67 | * this method is supposed to parse and return so that clients can | |
68 | * choose the hash to be used. | |
69 | */ | |
70 | virtual HashStringList Hashes() const { return HashStringList(); }; | |
71 | APT_DEPRECATED std::string MD5Hash() const { return GetHashFromHashes("MD5Sum"); }; | |
72 | APT_DEPRECATED std::string SHA1Hash() const { return GetHashFromHashes("SHA1"); }; | |
73 | APT_DEPRECATED std::string SHA256Hash() const { return GetHashFromHashes("SHA256"); }; | |
74 | APT_DEPRECATED std::string SHA512Hash() const { return GetHashFromHashes("SHA512"); }; | |
75 | ||
7e798dd7 | 76 | // These are some general stats about the package |
8f3ba4e8 | 77 | virtual std::string Maintainer() {return std::string();}; |
ffe3c68e DK |
78 | /** return short description in language from record. |
79 | * | |
80 | * @see #LongDesc | |
81 | */ | |
82 | virtual std::string ShortDesc(std::string const &/*lang*/) {return std::string();}; | |
83 | /** return long description in language from record. | |
84 | * | |
85 | * If \b lang is empty the "best" available language will be | |
86 | * returned as determined by the APT::Languages configuration. | |
87 | * If a (requested) language can't be found in this record an empty | |
88 | * string will be returned. | |
89 | */ | |
90 | virtual std::string LongDesc(std::string const &/*lang*/) {return std::string();}; | |
91 | std::string ShortDesc() {return ShortDesc("");}; | |
92 | std::string LongDesc() {return LongDesc("");}; | |
93 | ||
8f3ba4e8 DK |
94 | virtual std::string Name() {return std::string();}; |
95 | virtual std::string Homepage() {return std::string();} | |
75bda619 MV |
96 | |
97 | // An arbitrary custom field | |
65512241 | 98 | virtual std::string RecordField(const char * /*fieldName*/) { return std::string();}; |
75bda619 | 99 | |
b2e465d6 AL |
100 | // The record in binary form |
101 | virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;}; | |
102 | ||
f55ece0e | 103 | virtual ~Parser() {}; |
b3501edb DK |
104 | |
105 | private: | |
106 | APT_HIDDEN std::string GetHashFromHashes(char const * const type) const | |
107 | { | |
108 | HashStringList const hashes = Hashes(); | |
109 | HashString const * const hs = hashes.find(type); | |
110 | return hs != NULL ? hs->HashValue() : ""; | |
111 | }; | |
f55ece0e | 112 | }; |
92fcbfc1 | 113 | /*}}}*/ |
f55ece0e | 114 | #endif |