]> git.saurik.com Git - apt.git/blob - apt-pkg/srcrecords.h
merge with current debian apt/experimental
[apt.git] / apt-pkg / srcrecords.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: srcrecords.h,v 1.8.2.1 2003/12/26 16:27:34 mdz Exp $
4 /* ######################################################################
5
6 Source Package Records - Allows access to source package records
7
8 Parses and allows access to the list of source records and searching by
9 source name on that list.
10
11 ##################################################################### */
12 /*}}}*/
13 #ifndef PKGLIB_SRCRECORDS_H
14 #define PKGLIB_SRCRECORDS_H
15
16
17 #include <string>
18 #include <vector>
19
20 class pkgSourceList;
21 class pkgIndexFile;
22 class pkgSrcRecords
23 {
24 public:
25
26 // Describes a single file
27 struct File
28 {
29 std::string MD5Hash;
30 unsigned long Size;
31 std::string Path;
32 std::string Type;
33 };
34
35 // Abstract parser for each source record
36 class Parser
37 {
38 protected:
39
40 const pkgIndexFile *iIndex;
41
42 public:
43
44 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
45 BuildConflict=0x2,BuildConflictIndep=0x3};
46
47 struct BuildDepRec
48 {
49 std::string Package;
50 std::string Version;
51 unsigned int Op;
52 unsigned char Type;
53 };
54
55 inline const pkgIndexFile &Index() const {return *iIndex;};
56
57 virtual bool Restart() = 0;
58 virtual bool Step() = 0;
59 virtual bool Jump(unsigned long const &Off) = 0;
60 virtual unsigned long Offset() = 0;
61 virtual std::string AsStr() = 0;
62
63 virtual std::string Package() const = 0;
64 virtual std::string Version() const = 0;
65 virtual std::string Maintainer() const = 0;
66 virtual std::string Section() const = 0;
67 virtual const char **Binaries() = 0; // Ownership does not transfer
68
69 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
70 static const char *BuildDepType(unsigned char const &Type);
71
72 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
73
74 Parser(const pkgIndexFile *Index) : iIndex(Index) {};
75 virtual ~Parser() {};
76 };
77
78 private:
79 /** \brief dpointer placeholder (for later in case we need it) */
80 void *d;
81
82 // The list of files and the current parser pointer
83 std::vector<Parser*> Files;
84 std::vector<Parser *>::iterator Current;
85
86 public:
87
88 // Reset the search
89 bool Restart();
90
91 // Locate a package by name
92 Parser *Find(const char *Package,bool const &SrcOnly = false);
93
94 pkgSrcRecords(pkgSourceList &List);
95 virtual ~pkgSrcRecords();
96 };
97
98 #endif