]>
Commit | Line | Data |
---|---|---|
11e7af84 AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
7db98ffc | 3 | // $Id: srcrecords.h,v 1.8.2.1 2003/12/26 16:27:34 mdz Exp $ |
11e7af84 AL |
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 | #ifdef __GNUG__ | |
17 | #pragma interface "apt-pkg/srcrecords.h" | |
18 | #endif | |
19 | ||
b2e465d6 AL |
20 | #include <string> |
21 | #include <vector> | |
11e7af84 | 22 | |
0a843901 AL |
23 | using std::string; |
24 | using std::vector; | |
25 | ||
b2e465d6 AL |
26 | class pkgSourceList; |
27 | class pkgIndexFile; | |
11e7af84 AL |
28 | class pkgSrcRecords |
29 | { | |
30 | public: | |
36f610f1 AL |
31 | |
32 | // Describes a single file | |
33 | struct File | |
34 | { | |
35 | string MD5Hash; | |
36 | unsigned long Size; | |
37 | string Path; | |
b2e465d6 | 38 | string Type; |
36f610f1 | 39 | }; |
11e7af84 | 40 | |
36f610f1 | 41 | // Abstract parser for each source record |
11e7af84 AL |
42 | class Parser |
43 | { | |
b2e465d6 AL |
44 | protected: |
45 | ||
46 | const pkgIndexFile *iIndex; | |
36375005 | 47 | |
11e7af84 AL |
48 | public: |
49 | ||
b2e465d6 AL |
50 | enum BuildDep {BuildDepend=0x0,BuildDependIndep=0x1, |
51 | BuildConflict=0x2,BuildConflictIndep=0x3}; | |
52 | ||
53 | struct BuildDepRec | |
54 | { | |
55 | string Package; | |
56 | string Version; | |
57 | unsigned int Op; | |
58 | unsigned char Type; | |
59 | }; | |
60 | ||
61 | inline const pkgIndexFile &Index() const {return *iIndex;}; | |
36375005 | 62 | |
11e7af84 AL |
63 | virtual bool Restart() = 0; |
64 | virtual bool Step() = 0; | |
65 | virtual bool Jump(unsigned long Off) = 0; | |
66 | virtual unsigned long Offset() = 0; | |
f8f410f5 | 67 | virtual string AsStr() = 0; |
11e7af84 | 68 | |
b2e465d6 AL |
69 | virtual string Package() const = 0; |
70 | virtual string Version() const = 0; | |
71 | virtual string Maintainer() const = 0; | |
72 | virtual string Section() const = 0; | |
73 | virtual const char **Binaries() = 0; // Ownership does not transfer | |
74 | ||
45430cbf | 75 | virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps, bool ArchOnly) = 0; |
b2e465d6 AL |
76 | static const char *BuildDepType(unsigned char Type); |
77 | ||
727f18af | 78 | virtual bool Files(vector<pkgSrcRecords::File> &F) = 0; |
11e7af84 | 79 | |
b2e465d6 AL |
80 | Parser(const pkgIndexFile *Index) : iIndex(Index) {}; |
81 | virtual ~Parser() {}; | |
11e7af84 AL |
82 | }; |
83 | ||
84 | private: | |
85 | ||
86 | // The list of files and the current parser pointer | |
7db98ffc MZ |
87 | vector<Parser*> Files; |
88 | vector<Parser *>::iterator Current; | |
11e7af84 AL |
89 | |
90 | public: | |
91 | ||
92 | // Reset the search | |
93 | bool Restart(); | |
94 | ||
95 | // Locate a package by name | |
96 | Parser *Find(const char *Package,bool SrcOnly = false); | |
97 | ||
98 | pkgSrcRecords(pkgSourceList &List); | |
99 | ~pkgSrcRecords(); | |
100 | }; | |
101 | ||
11e7af84 | 102 | #endif |