]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgrecords.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgrecords.h,v 1.6 2001/03/13 06:51:46 jgg Exp $
4 /* ######################################################################
6 Package Records - Allows access to complete package description records
7 directly from the file.
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.
15 ##################################################################### */
17 #ifndef PKGLIB_PKGRECORDS_H
18 #define PKGLIB_PKGRECORDS_H
20 #include <apt-pkg/pkgcache.h>
21 #include <apt-pkg/hashes.h>
22 #include <apt-pkg/macros.h>
27 class pkgRecords
/*{{{*/
33 /** \brief dpointer placeholder (for later in case we need it) */
37 std::vector
<Parser
*>Files
;
41 Parser
&Lookup(pkgCache::VerFileIterator
const &Ver
);
42 Parser
&Lookup(pkgCache::DescFileIterator
const &Desc
);
45 explicit pkgRecords(pkgCache
&Cache
);
46 virtual ~pkgRecords();
49 class pkgRecords::Parser
/*{{{*/
53 virtual bool Jump(pkgCache::VerFileIterator
const &Ver
) = 0;
54 virtual bool Jump(pkgCache::DescFileIterator
const &Desc
) = 0;
57 friend class pkgRecords
;
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();};
64 /** return all known hashes in this record.
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.
70 virtual HashStringList
Hashes() const { return HashStringList(); };
71 APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string
MD5Hash() const { return GetHashFromHashes("MD5Sum"); };
72 APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string
SHA1Hash() const { return GetHashFromHashes("SHA1"); };
73 APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string
SHA256Hash() const { return GetHashFromHashes("SHA256"); };
74 APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string
SHA512Hash() const { return GetHashFromHashes("SHA512"); };
76 // These are some general stats about the package
77 virtual std::string
Maintainer() {return std::string();};
78 /** return short description in language from record.
82 virtual std::string
ShortDesc(std::string
const &/*lang*/) {return std::string();};
83 /** return long description in language from record.
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.
90 virtual std::string
LongDesc(std::string
const &/*lang*/) {return std::string();};
91 std::string
ShortDesc() {return ShortDesc("");};
92 std::string
LongDesc() {return LongDesc("");};
94 virtual std::string
Name() {return std::string();};
95 virtual std::string
Display() {return std::string();}
96 virtual std::string
Homepage() {return std::string();}
98 // An arbitrary custom field
99 virtual std::string
RecordField(const char * /*fieldName*/) { return std::string();};
101 // The record in binary form
102 virtual void GetRec(const char *&Start
,const char *&Stop
) {Start
= Stop
= 0;};
105 virtual bool Find(const char *Tag
,const char *&Start
, const char *&End
) {Start
= End
= 0; return false;};
112 APT_HIDDEN
std::string
GetHashFromHashes(char const * const type
) const
114 HashStringList
const hashes
= Hashes();
115 HashString
const * const hs
= hashes
.find(type
);
116 return hs
!= NULL
? hs
->HashValue() : "";