]> git.saurik.com Git - apt.git/blob - apt-pkg/srcrecords.h
releasing package apt version 1.0.5
[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 #include <apt-pkg/macros.h>
17
18 #include <string>
19 #include <vector>
20
21 #ifndef APT_8_CLEANER_HEADERS
22 using std::string;
23 using std::vector;
24 #endif
25
26 class pkgSourceList;
27 class pkgIndexFile;
28 class pkgSrcRecords
29 {
30 public:
31
32 // Describes a single file
33 struct File
34 {
35 std::string MD5Hash;
36 unsigned long Size;
37 std::string Path;
38 std::string Type;
39 };
40
41 // Abstract parser for each source record
42 class Parser
43 {
44 protected:
45
46 const pkgIndexFile *iIndex;
47
48 public:
49
50 enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1,
51 BuildConflict=0x2,BuildConflictIndep=0x3};
52
53 struct BuildDepRec
54 {
55 std::string Package;
56 std::string Version;
57 unsigned int Op;
58 unsigned char Type;
59 };
60
61 inline const pkgIndexFile &Index() const {return *iIndex;};
62
63 virtual bool Restart() = 0;
64 virtual bool Step() = 0;
65 virtual bool Jump(unsigned long const &Off) = 0;
66 virtual unsigned long Offset() = 0;
67 virtual std::string AsStr() = 0;
68
69 virtual std::string Package() const = 0;
70 virtual std::string Version() const = 0;
71 virtual std::string Maintainer() const = 0;
72 virtual std::string Section() const = 0;
73 virtual const char **Binaries() = 0; // Ownership does not transfer
74
75 //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
76 virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
77 static const char *BuildDepType(unsigned char const &Type) APT_PURE;
78
79 virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0;
80
81 Parser(const pkgIndexFile *Index) : iIndex(Index) {};
82 virtual ~Parser() {};
83 };
84
85 private:
86 /** \brief dpointer placeholder (for later in case we need it) */
87 void *d;
88
89 // The list of files and the current parser pointer
90 std::vector<Parser*> Files;
91 std::vector<Parser *>::iterator Current;
92
93 public:
94
95 // Reset the search
96 bool Restart();
97
98 // Step to the next SourcePackage and return pointer to the
99 // next SourceRecord. The pointer is owned by libapt.
100 const Parser* Step();
101
102 // Locate a package by name and return pointer to the Parser.
103 // The pointer is owned by libapt.
104 Parser* Find(const char *Package,bool const &SrcOnly = false);
105
106 pkgSrcRecords(pkgSourceList &List);
107 virtual ~pkgSrcRecords();
108 };
109
110 #endif