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